0
我對Grunt還是比較陌生的,所以也許有更多經驗的人可以幫助我。出於某種原因,我運行grunt watch
時,uglify任務正在執行多次,所以我的scripts.min.js文件被多次編譯。Grunt Uglify Loop
這是我的Gruntfile.js目前的樣子:
'use strict';
module.exports = function(grunt) {
// Show elapsed time
require('time-grunt')(grunt);
// Comment out any unused components
var jsFiles = [
//'assets/vendor/bootstrap-sass-official/assets/javascripts/bootstrap/affix.js',
//'assets/vendor/bootstrap-sass-official/assets/javascripts/bootstrap/alert.js',
//'assets/vendor/bootstrap-sass-official/assets/javascripts/bootstrap/button.js',
//'assets/vendor/bootstrap-sass-official/assets/javascripts/bootstrap/carousel.js',
'assets/vendor/bootstrap-sass-official/assets/javascripts/bootstrap/collapse.js',
//'assets/vendor/bootstrap-sass-official/assets/javascripts/bootstrap/dropdown.js',
//'assets/vendor/bootstrap-sass-official/assets/javascripts/bootstrap/modal.js',
//'assets/vendor/bootstrap-sass-official/assets/javascripts/bootstrap/popover.js',
//'assets/vendor/bootstrap-sass-official/assets/javascripts/bootstrap/scrollspy.js',
//'assets/vendor/bootstrap-sass-official/assets/javascripts/bootstrap/tab.js',
//'assets/vendor/bootstrap-sass-official/assets/javascripts/bootstrap/tooltip.js',
'assets/vendor/bootstrap-sass-official/assets/javascripts/bootstrap/transition.js',
'assets/js/*.js'
];
// Configure tasks.
grunt.initConfig({
sass: {
dist: {
options: {
style: 'compressed'
},
files: {
'assets/css/main.min.css': 'assets/sass/app.scss',
'assets/css/custom-login.min.css': 'assets/sass/_login.scss',
'assets/css/magnific.min.css': 'assets/sass/plugins/magnific/magnific.scss'
}
}
},
uglify: {
dist: {
files: {
'assets/js/scripts.min.js': [ jsFiles ]
}
}
},
watch: {
sass: {
files: [ 'assets/sass/*.scss' ],
tasks: [ 'sass' ]
},
js: {
files: [ jsFiles ],
tasks: [ 'uglify' ]
}
}
});
// Load tasks.
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-sass');
// Register tasks.
grunt.registerTask('default', [
'watch',
'sass',
'uglify'
]);
};
任何人有,爲什麼醜化任務執行多次任何想法?
不錯!做了一個魅力! –