嗨,我用Grunt把我的较少的代码编译成CSS。要查看是否对我的.less文件进行了更改,请使用:
grunt watch在这样做之后,我编辑了我的.less文件。但是在cmd中什么都没有发生,我仍然看到他在监视我的.less文件。下面是它的截图:
链接:http://i.imgur.com/hT8l18f.png
下面是我使用的代码:
gruntfile.js:
module.exports = function(grunt) {
grunt.initConfig({
less: {
development: {
options: {
compress: true,
yuicompress: true,
optimization: 2
},
files: {
"css/styles.css": "css/styles.less" // destination file and source file
}
}
},
watch: {
styles: {
files: ['less/styles.less'], // which files to watch
tasks: ['less'],
options: {
nospawn: true
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['less', 'watch']);
};package.json:
{
"name": "Coming_soon_code",
"version": "0.0.0",
"description": "van een tut",
"main": "gruntfile.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "BSD-2-Clause",
"devDependencies": {
"grunt": "~0.4.5",
"grunt-contrib-less": "~1.0.0",
"grunt-contrib-watch": "~0.6.1"
}
}这里还有我的文件夹结构的屏幕截图,如果您需要的话:
链接:http://i.imgur.com/WWAJZb0.png
发布于 2014-12-27 23:13:48
你似乎在“看”'less/styles.less'文件.但根据屏幕截图或less任务配置,这不是正确的目录,而是在css目录中。也许试一试:
watch: {
styles: {
files: ['css/styles.less'], // <-- changed the directory here...
tasks: ['less'],
options: {
nospawn: true
}
}
}https://stackoverflow.com/questions/27672190
复制相似问题