我在grunt-contrib-cssmin上遇到了一个奇怪的问题。它永远不会停止或给出错误。我在用
C:\ projects \ doeclf> grunt --version &&节点--version && npm --version
grunt-cli v0.1.13
咕unt v0.4.5
v0.12.4
2.10.1
我的grunt.js中有以下内容
cssmin: {
target: {
files: [{
expand: true,
cwd: 'css/',
src: ['index.css', '!*.min.css'],
dest: 'css/',
ext: '.min.css'
}]
}
}
我的项目结构如下
| | grunt.js | |__css | |__index.css
When I run my grunt task this is the out it throws and it never finishes.
the output from my grunt cssmin --verbose is
[4mInitializing[24m
Command-line options: [36m--verbose[39m
Reading "Gruntfile.js" Gruntfile...[32mOK[39m
[1mRegistering Gruntfile tasks.[22m
Reading package.json...[32mOK[39m
Parsing package.json...[32mOK[39m
Initializing config...[32mOK[39m
[1mRegistering "grunt-contrib-requirejs" local Npm module tasks.[22m
Reading C:\projects\doeclf\node_modules\grunt-contrib-requirejs\package.json...[32mOK[39m
Parsing C:\projects\doeclf\node_modules\grunt-contrib-requirejs\package.json...[32mOK[39m
Loading "requirejs.js" tasks...[32mOK[39m
+ [36mrequirejs[39m
[1mRegistering "grunt-contrib-compass" local Npm module tasks.[22m
Reading C:\projects\doeclf\node_modules\grunt-contrib-compass\package.json...[32mOK[39m
Parsing C:\projects\doeclf\node_modules\grunt-contrib-compass\package.json...[32mOK[39m
Loading "compass.js" tasks...[32mOK[39m
+ [36mcompass[39m
[1mRegistering "grunt-contrib-concat" local Npm module tasks.[22m
Reading C:\projects\doeclf\node_modules\grunt-contrib-concat\package.json...[32mOK[39m
Parsing C:\projects\doeclf\node_modules\grunt-contrib-concat\package.json...[32mOK[39m
Loading "concat.js" tasks...[32mOK[39m
+ [36mconcat[39m
[1mRegistering "grunt-contrib-connect" local Npm module tasks.[22m
Reading C:\projects\doeclf\node_modules\grunt-contrib-connect\package.json...[32mOK[39m
Parsing C:\projects\doeclf\node_modules\grunt-contrib-connect\package.json...[32mOK[39m
Loading "connect.js" tasks...[32mOK[39m
+ [36mconnect[39m
[1mRegistering "grunt-contrib-cssmin" local Npm module tasks.[22m
Reading C:\projects\doeclf\node_modules\grunt-contrib-cssmin\package.json...[32mOK[39m
Parsing C:\projects\doeclf\node_modules\grunt-contrib-cssmin\package.json...[32mOK[39m
Loading "cssmin.js" tasks...[32mOK[39m
+ [36mcssmin[39m
[1mRegistering "csswring" local Npm module tasks.[22m
Reading C:\projects\doeclf\node_modules\csswring\package.json...[32mOK[39m
Parsing C:\projects\doeclf\node_modules\csswring\package.json...[32mOK[39m
Loading "csswring.js" tasks...[32mOK[39m
+ [36mcsswring[39m
[1mRegistering "grunt-contrib-sass" local Npm module tasks.[22m
Reading C:\projects\doeclf\node_modules\grunt-contrib-sass\package.json...[32mOK[39m
Parsing C:\projects\doeclf\node_modules\grunt-contrib-sass\package.json...[32mOK[39m
Loading "sass.js" tasks...[32mOK[39m
+ [36msass[39m
[1mRegistering "grunt-contrib-uglify" local Npm module tasks.[22m
Reading C:\projects\doeclf\node_modules\grunt-contrib-uglify\package.json...[32mOK[39m
Parsing C:\projects\doeclf\node_modules\grunt-contrib-uglify\package.json...[32mOK[39m
Loading "uglify.js" tasks...[32mOK[39m
+ [36muglify[39m
[1mRegistering "grunt-contrib-watch" local Npm module tasks.[22m
Reading C:\projects\doeclf\node_modules\grunt-contrib-watch\package.json...[32mOK[39m
Parsing C:\projects\doeclf\node_modules\grunt-contrib-watch\package.json...[32mOK[39m
Loading "watch.js" tasks...[32mOK[39m
+ [36mwatch[39m
[1mRegistering "grunt-express" local Npm module tasks.[22m
Reading C:\projects\doeclf\node_modules\grunt-express\package.json...[32mOK[39m
Parsing C:\projects\doeclf\node_modules\grunt-express\package.json...[32mOK[39m
[1mRegistering "grunt-parallel" local Npm module tasks.[22m
Reading C:\projects\doeclf\node_modules\grunt-express\node_modules\grunt-parallel\package.json...[32mOK[39m
Parsing C:\projects\doeclf\node_modules\grunt-express\node_modules\grunt-parallel\package.json...[32mOK[39m
Loading "parallel.js" tasks...[32mOK[39m
+ [36mparallel[39m
Loading "express.js" tasks...[32mOK[39m
+ [36mexpress[39m, [36mexpress-keepalive[39m, [36mexpress-restart[39m, [36mexpress-server[39m, [36mexpress-start[39m
[1mRegistering "grunt-open" local Npm module tasks.[22m
Reading C:\projects\doeclf\node_modules\grunt-open\package.json...[32mOK[39m
Parsing C:\projects\doeclf\node_modules\grunt-open\package.json...[32mOK[39m
Loading "open.js" tasks...[32mOK[39m
+ [36mopen[39m
Loading "Gruntfile.js" tasks...[32mOK[39m
+ [36mbuildsass[39m, [36mconcatcss[39m, [36mcssmin[39m, [36mdefault[39m, [36mserver[39m
Running tasks: [36mcssmin[39m
[4mRunning "cssmin" task[24m
[4mRunning "cssmin" task[24m
[4mRunning "cssmin" task[24m
[4mRunning "cssmin" task[24m
[4mRunning "cssmin" task[24m
最佳答案
您的目标很好并且可以完美运行,因此问题出在代码的其他地方。
具体来说,最后一行显示您正在重新定义自己的cssmin
任务Loading "Gruntfile.js" tasks...[32mOK[39m+ [36mbuildsass[39m, [36mconcatcss[39m, [36mcssmin[39m, [36mdefault[39m, [36mserver[39m
这可能会导致无限循环,将您自己的任务命名为其他名称(mincss?),就可以了。