Grunt grunt-contrib-cssmin 无休止地运行不合并文件

Grunt grunt-contrib-cssmin runs unending doesn't combine files

我在使用 g运行t-contrib-cssmin 时遇到了一个奇怪的问题。它永远不会停止或给出错误。我正在使用

C:\projects\doeclf>g运行t --version && node --version && npm --version g运行t-cli v0.1.13 g运行t 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  
 

当我 运行 我的 g运行t 任务时,这是它抛出的结果,它永远不会完成。

我的 g运行t 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:\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?)应该没问题。