您好我正在使用Grunt将较少的代码编译为CSS。要查看我是否对我的.less文件进行了更改,请使用:
grunt watch
这样做之后,我正在编辑我的.less文件。但在cmd中没有任何反应我仍然看到他正在看我的.less文件。以下是它的截图:
link: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"
}
}
此处还有我的文件夹结构的屏幕截图,以备不时之需:
答案 0 :(得分:1)
您似乎正在“观看”'less/styles.less'
文件...但根据您的屏幕截图或less
任务配置,这不是正确的目录,它位于css
目录中。试试吧:
watch: {
styles: {
files: ['css/styles.less'], // <-- changed the directory here...
tasks: ['less'],
options: {
nospawn: true
}
}
}