module.exports = function (grunt) {
require('time-grunt')(grunt);
require('load-grunt-tasks')(grunt);
grunt.initConfig({
//define pkg object and point to package.json
pkg: grunt.file.readJSON('package.json'),
//define notifications
notify_hooks: {
options: {
enabled: true,
max_jshint_notifications: 5, // maximum number of notifications from jshint output
title: "<%= pkg.name %>", // defaults to the name in package.json, or will use project directory's name
success: false, // whether successful grunt executions should be notified automatically
duration: 3 // the duration of notification in seconds, for `notify-send only
}
},
notify: {
build: {
options: {
title: '<%= pkg.name %> Build',
message: 'Build Completed'
}
},
js: {
options: {
message: 'Completed JS Build'
}
},
css: {
options: {
message: 'Completed CSS Build'
}
},
bower: {
options: {
message: 'Completed Bower'
}
}
},
//define clean task
clean: {
bower: ["<%= bower.install.options.targetDir %>", "bower_components"]
},
//define bower task
bower: {
install: {
options: {
cleanTargetDir: true,
targetDir: '<%= pkg.dist_dir %>/lib'
}
}
},
bower_concat: {
all: {
dest: '<%= pkg.dist_dir %>/lib/_bower.js',
cssDest: '<%= pkg.dist_dir %>/lib/_bower.css',
bowerOptions: {
relative: false
},
dependencies: {
'angular': ['jquery', 'moment'],
'datePicker': ['moment']
},
mainFiles: {
'ng-flags': 'src/directives/ng-flags.js'
},
includeDev: true
}
},
//define concat task to concat all js files
concat: {
js: {
options: {
separator: '\n'
},
src: [
'js/app/app.js', 'js/**/*.js'
],
dest: '<%= pkg.dist_dir %>/<%= pkg.name %>.js'
}
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n',
mangle: false
},
js: {
files: {
'<%= pkg.dist_dir %>/<%= pkg.name %>.min.js': ['<%= concat.js.dest %>']
}
}
},
jshint: {
files: ['Gruntfile.js', 'js/**/*.js', '!js/lib/*.js'],
options: {
globals: {
jQuery: true,
console: true,
module: true
}
}
},
//define less task
less: {
all: {
options: {
paths: ["css"]
},
files: {
"<%= pkg.dist_dir %>/<%= pkg.name %>.css": "css/<%= pkg.name %>.less"
}
}
},
less_imports: {
options: {
inlineCSS: false
},
all: {
src: [ 'css/**/*.less', '!<%= less_imports.all.dest %>', '!css/<%= pkg.name %>.less'],
dest: 'css/auto_imports.less'
}
},
//define the watch task. (documented at https://github.com/gruntjs/grunt-contrib-watch)
watch: {
js: {
files: ['<%= concat.js.src %>'],
tasks: ['build_js']
},
css: {
files: ['css/**/*.less'],
tasks: ['build_css']
},
grunt_file: {
files: ['Gruntfile.js'],
tasks: ['build']
}
}
});
//bower tasks
grunt.registerTask('bower_install', [ 'clean:bower', 'bower', 'bower_concat', 'notify:bower']);
grunt.registerTask('build_css', ['less_imports', 'less', 'notify:css']);
grunt.registerTask('build_js', ['jshint', 'concat:js', 'uglify:js', 'notify:js']);
// the default task can be run just by typing "grunt" on the command line
grunt.registerTask('build', [
'bower_install', 'build_css', 'build_js'
]);
grunt.registerTask('default', ['build']);
// Start the notification task.
grunt.task.run('notify_hooks');
};
私は同じ問題を抱えています(私は全く嫌な思いをしています)あなたはこれを理解しましたか? – GMA
私はGruntfileを一から書き直してしまったので、それがあなたに役立つかどうかを知るための答えとして投稿します。 – ecorvo
私の答えとLMKがあなたのために表示されている場合 – ecorvo