i have this tasks in gruntfile.js
and when I run: grunt default Loading "gruntfile.js" tasks...ERROR
SyntaxError: Unexpected token : Warning: Task "default" not found. Use --force to continue.
Aborted due to warnings.
i don't find where is the error in my code.
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
//uglify
uglify: {
options: {
mangle: false,
compress: {
drop_console: true
}
},
js: {
files: [{
cwd: 'assets/javascripts/',
expand: true,
src: '*.js',
dest: 'assets/javascripts/min/'
}]
}
}
});
sass: {
// this is the "dev" Sass config used with "grunt watch" command
dev: {
options: {
style: 'expanded',
// tell Sass to look in the Bootstrap stylesheets directory when compiling
loadPath: 'assets/stylesheets/sass/'
},
files: {
// the first path is the output and the second is the input
'sass/main.css': 'assets/styleheets/sass/main.scss'
}
},
// this is the "production" Sass config used with the "grunt buildcss" command
dist: {
options: {
style: 'compressed',
loadPath: 'assets/stylesheets'
},
files: {
'sass/main.css': 'assets/stylesheets/sass/main.scss'
}
}
},
// configure the "grunt watch" task
watch: {
sass: {
files: 'sass/*.scss',
tasks: ['sass:dev']
}
}
});
// loadNpmTasks
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
// Run Default task(s).
grunt.registerTask('default', ['uglify', 'watch', 'buildcss']);
};
答案 0 :(得分:0)
您的定义没有正确嵌套,您应该在sass
块中移动watch
和grunt.initConfig
,并将grunt.registerTask, grunt.loadNpmTasks
指令移到function(grunt) {}
的末尾阻止,就像那样:
module.exports = function (grunt) {
grunt.initConfig({
uglify: {},
sass : {},
watch : {}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['uglify', 'watch', 'buildcss']);
};