在我的项目grunt文件中,我的监视任务似乎正在启动,然后立即退出。
请查看附件中的截图。
请找到我的Gruntfile.js的代码;
module.exports = function (grunt) {
grunt.initConfig({
sass: {
options: {
cacheLocation: '.sass-cache'
},
prod: {
options: {
style: 'compressed'
},
files: [{
'assets/css/dist/main.min.css': 'assets/css/sass/main.scss'
}]
},
dev: {
options: {
style: 'nested'
},
files: [{
'assets/css/main.css': 'assets/css/sass/main.scss'
}]
}
},
imageoptim: {
files: [
'img/flat',
'img/flat/**'
],
options: {
imageAlpha: true,
jpegMini: true,
quitAfter: true
}
},
uglify: {
options: {
mangle: true,
compress: true
},
jsCompress: {
files: {
'js/dist/main.min.js': ['js/src/script1.js', 'js/src/script2.js']
}
}
},
concat: {
options: {
separator: ';',
},
dist: {
src: ['js/src/script1.js', 'js/src/script2.js'],
dest: 'js/dist/main.min.js',
}
},
watch: {
sassWatch: {
files: 'css/sass/**/*.scss',
tasks: ['sass:prod', 'sass:dev'],
},
JsWatch: {
files: ['js/modules/script1.js', 'js/modules/script2.js'],
tasks: ['uglify:jsCompress', 'concat:dist'],
}
},
notify: {
sassNotify: {
options: {
title: "Task Complete",
message: "Your Sass has been compiled and concatanatated!"
}
},
jsNotify: {
options: {
title: "Task Complete",
message: "Your JS has been minified and concatanatated!"
}
},
imageNotify: {
options: {
title: "Task Complete",
message: "All images have been compressed"
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-imageoptim');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-notify');
grunt.registerTask('sassNotify', 'watch:sassWatch');
grunt.registerTask('jsNotify', 'watch:jsWatch');
grunt.registerTask('imageNotify', 'imageoptim');
};有谁知道为什么会发生这种事吗?
致以亲切的问候,
B!

发布于 2015-06-18 22:13:47
我的问题是它在监视很多我有跟踪的100+图像文件,所以我只是指定它应该看什么(js,html,scss,css)。
发布于 2014-02-23 03:15:59
我遇到了这个问题,正在寻找答案。在我的例子中,我的files:匹配模式中有一个拼写错误,这导致它找不到要监视和中止的目录,尽管错误消息会很好。我注意到,在您的sass任务中,您使用assets/作为文件的前缀,而不是在监视任务中。
我知道你可能已经离开了,但希望这对未来的人有所帮助。
发布于 2014-03-18 08:56:38
试试像这样的东西
....
watch: {
dev: {
files: 'assets/sass/**/*{.scss,.js}',
tasks: ['sass:dev','uglify:jsCompress'],
},
},
...
});
grunt.registerTask('dev', 'watch:dev');watch task in my gruntfile可能会有所帮助。
https://stackoverflow.com/questions/18225206
复制相似问题