→ grunt Running "stylus:compile" (stylus) task File 'css/styles.css' created. Running "concat:js" (concat) task File "project.js" created. Running "lint:files" (lint) task Lint free. Running "min:js" (min) task File "project.min.js" created. Uncompressed size: 130468 bytes. Compressed size: 20937 bytes gzipped (74246 bytes minified). Running "qunit:all" (qunit) task Testing index.html...............OK >> 95 assertions passed (594ms) Running "watch" task Waiting...
module.exports = function(grunt) { grunt.initConfig({ stylus: { // Stylus CSS compile: { options: { 'compress': true, 'paths': ['css/styl/'] }, files: { 'css/styles.css': 'css/styles.styl' } } }, concat: { // js- js: { src: [ /* */ ], dest: 'project.js' } }, min: { // js: { src: ['<config:concat.js.dest>'], dest: 'project.min.js' } }, jshint: { options: { smarttabs: true } }, lint: { // files: ['<config:concat.js.dest>'] }, watch: { // styl- stylus: { files: ['css/styl/*.styl'], tasks: 'stylus' }, // lint js- js: { files: ['src/*.js'], tasks: 'concat lint' } }, qunit: { // qUnit- all: ['../test/index.html'] } }); // grunt.loadNpmTasks('grunt-stylus'); // grunt.registerTask('default', 'stylus concat:js lint min:js qunit watch'); grunt.registerTask('test', 'qunit'); };
npm uninstall -g grunt
: npm uninstall -g grunt
npm install -g grunt-cli
npm install grunt
→ grunt --version grunt-cli v0.1.6 grunt v0.4.0
mv grunt.js Gruntfile.js
Fatal error: Unable to find Gruntfile.
→ npm install grunt-contrib-concat → npm install grunt-contrib-jshint → npm install grunt-contrib-uglify → npm install grunt-contrib-qunit → npm install grunt-contrib-watch → npm install grunt-contrib-stylus
--save-dev
parameter to automatically update the dependencies of devDependencies in package.json. grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-qunit'); grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-contrib-stylus');
grunt.registerTask('test', 'qunit');
grunt.registerTask('default', ['stylus', 'concat:js', 'jshint', 'min:js', 'qunit', 'watch']);
<config:concat.js.dest>
now use the templates: <%= concat.js.dest %>
. jshint: { options: { smarttabs: true }, js: ['project.js'] }
uglify: { js: { files: { 'project.min.js': ['<%= concat.js.dest %>'] } } }
watch: { js: { files: ['src/*.js'], tasks: ['concat', 'lint'] } }
module.exports = function(grunt) { grunt.initConfig({ // Stylus CSS stylus: { compile: { options: { 'compress': true, 'paths': ['css/styl/'] }, files: { 'css/styles.css': 'css/styles.styl' } } }, concat: { // js- js: { src: [ /* */ ], dest: 'project.js' } }, uglify: { // js: { files: { 'project.min.js': ['<%= concat.js.dest %>'] } } }, jshint: { // options: { smarttabs: true }, js: ['<%= concat.js.dest %>'] }, watch: { // styl- stylus: { files: ['css/styl/*.styl'], tasks: 'stylus' }, // lint js- js: { files: ['src/*.js'], tasks: ['concat', 'lint'] } }, qunit: { // qUnit- all: ['../test/index.html'] } }); grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-qunit'); grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-contrib-stylus'); // grunt.registerTask('default', ['stylus', 'concat:js', 'jshint', 'uglify:js', 'qunit', 'watch']); grunt.registerTask('test', 'qunit'); };
Source: https://habr.com/ru/post/170937/
All Articles