我在grunt-contrib-cssmin上遇到了一个奇怪的问题。它从不停止或给出错误。我正在使用
C:projectsdoeclf>grunt——version &&节点——版本&&npm——版本grunt-cli v0.1.13繁重v0.4.5v0.12.42.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之前当我运行我的grunt任务时,这是它抛出的,它永远不会结束。
我的grunt cssmin——verbose的输出是
[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:projectsdoeclfnode_modulesgrunt-contrib-requirejspackage.json...[32mOK[39m
Parsing C:projectsdoeclfnode_modulesgrunt-contrib-requirejspackage.json...[32mOK[39m
Loading "requirejs.js" tasks...[32mOK[39m
+ [36mrequirejs[39m
[1mRegistering "grunt-contrib-compass" local Npm module tasks.[22m
Reading C:projectsdoeclfnode_modulesgrunt-contrib-compasspackage.json...[32mOK[39m
Parsing C:projectsdoeclfnode_modulesgrunt-contrib-compasspackage.json...[32mOK[39m
Loading "compass.js" tasks...[32mOK[39m
+ [36mcompass[39m
[1mRegistering "grunt-contrib-concat" local Npm module tasks.[22m
Reading C:projectsdoeclfnode_modulesgrunt-contrib-concatpackage.json...[32mOK[39m
Parsing C:projectsdoeclfnode_modulesgrunt-contrib-concatpackage.json...[32mOK[39m
Loading "concat.js" tasks...[32mOK[39m
+ [36mconcat[39m
[1mRegistering "grunt-contrib-connect" local Npm module tasks.[22m
Reading C:projectsdoeclfnode_modulesgrunt-contrib-connectpackage.json...[32mOK[39m
Parsing C:projectsdoeclfnode_modulesgrunt-contrib-connectpackage.json...[32mOK[39m
Loading "connect.js" tasks...[32mOK[39m
+ [36mconnect[39m
[1mRegistering "grunt-contrib-cssmin" local Npm module tasks.[22m
Reading C:projectsdoeclfnode_modulesgrunt-contrib-cssminpackage.json...[32mOK[39m
Parsing C:projectsdoeclfnode_modulesgrunt-contrib-cssminpackage.json...[32mOK[39m
Loading "cssmin.js" tasks...[32mOK[39m
+ [36mcssmin[39m
[1mRegistering "csswring" local Npm module tasks.[22m
Reading C:projectsdoeclfnode_modulescsswringpackage.json...[32mOK[39m
Parsing C:projectsdoeclfnode_modulescsswringpackage.json...[32mOK[39m
Loading "csswring.js" tasks...[32mOK[39m
+ [36mcsswring[39m
[1mRegistering "grunt-contrib-sass" local Npm module tasks.[22m
Reading C:projectsdoeclfnode_modulesgrunt-contrib-sasspackage.json...[32mOK[39m
Parsing C:projectsdoeclfnode_modulesgrunt-contrib-sasspackage.json...[32mOK[39m
Loading "sass.js" tasks...[32mOK[39m
+ [36msass[39m
[1mRegistering "grunt-contrib-uglify" local Npm module tasks.[22m
Reading C:projectsdoeclfnode_modulesgrunt-contrib-uglifypackage.json...[32mOK[39m
Parsing C:projectsdoeclfnode_modulesgrunt-contrib-uglifypackage.json...[32mOK[39m
Loading "uglify.js" tasks...[32mOK[39m
+ [36muglify[39m
[1mRegistering "grunt-contrib-watch" local Npm module tasks.[22m
Reading C:projectsdoeclfnode_modulesgrunt-contrib-watchpackage.json...[32mOK[39m
Parsing C:projectsdoeclfnode_modulesgrunt-contrib-watchpackage.json...[32mOK[39m
Loading "watch.js" tasks...[32mOK[39m
+ [36mwatch[39m
[1mRegistering "grunt-express" local Npm module tasks.[22m
Reading C:projectsdoeclfnode_modulesgrunt-expresspackage.json...[32mOK[39m
Parsing C:projectsdoeclfnode_modulesgrunt-expresspackage.json...[32mOK[39m
[1mRegistering "grunt-parallel" local Npm module tasks.[22m
Reading C:projectsdoeclfnode_modulesgrunt-expressnode_modulesgrunt-parallelpackage.json...[32mOK[39m
Parsing C:projectsdoeclfnode_modulesgrunt-expressnode_modulesgrunt-parallelpackage.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:projectsdoeclfnode_modulesgrunt-openpackage.json...[32mOK[39m
Parsing C:projectsdoeclfnode_modulesgrunt-openpackage.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?),您应该没问题。