第一次运行Grunt构建时出错

时间:2014-02-06 20:24:27

标签: javascript angularjs build gruntjs yeoman

我使用Yeoman创建了一个angularJS项目

使用grunt serve预览应用效果很好。服务器启动,我可以成功浏览我的页面。

执行grunt build时我正在

Running "cdnify:dist" (cdnify) task
Going through dist/404.html, dist/index.html to update script refs
>> No "cssmin" targets found.
Warning: Task "cssmin" failed. Use --force to continue.

Aborted due to warnings.

我不知道如何解决或如何开始。我错过了一些配置吗?

现在配置:

  concat:
  { generated:
   { files:
      [ { dest: '.tmp\\concat\\scripts\\scripts.js',
          src:
           [ '{.tmp,app}\\cdnjs.cloudflare.com\\ajax\\libs\\noUiSlider\\5.0.0\\jquery.nouislider.min.js',
             .
             <MY_LIBRARIES>, 
             .] },
        { dest: '.tmp\\concat\\scripts\\modules.js',
          src:
           [ 'app\\scripts\\app.js',
             .
            <MY_SOURCE_FILES>, 
            . ] } ] } }

  uglify:
  { generated:
   { files:
      [ { dest: 'dist\\scripts\\scripts.js',
          src: [ '.tmp\\concat\\scripts\\scripts.js' ] },
        { dest: 'dist\\scripts\\modules.js',
          src: [ '.tmp\\concat\\scripts\\modules.js' ] } ] } }

  cssmin:
  {}

Running "concurrent:dist" (concurrent) task

Running "imagemin:dist" (imagemin) task
? app/images/yeoman.png (saved 9.06 kB)
Minified 1 image (saved 9.06 kB)

Done, without errors.

Running "svgmin:dist" (svgmin) task

Done, without errors.

Running "compass:dist" (compass) task
directory .tmp/styles/
       create .tmp/styles/bootstrap.css (1.739s)
       create .tmp/styles/main.css (0.129s)
       create .tmp/styles/problem-comprehension.css (0.002s)
       create .tmp/styles/problem-timedword.css (0.002s)
       create .tmp/styles/track-detail.css (0.009s)
    Compilation took 1.894s

Done, without errors.

Running "autoprefixer:dist" (autoprefixer) task
Prefixed file ".tmp/styles/bootstrap.css" created.
Prefixed file ".tmp/styles/main.css" created.
Prefixed file ".tmp/styles/problem-comprehension.css" created.
Prefixed file ".tmp/styles/problem-timedword.css" created.
Prefixed file ".tmp/styles/track-detail.css" created.

Running "concat:generated" (concat) task
File ".tmp\concat\scripts\scripts.js" created.
File ".tmp\concat\scripts\modules.js" created.

Running "ngmin:dist" (ngmin) task
ngminifying .tmp/concat/scripts/modules.js, .tmp/concat/scripts/scripts.js

Running "copy:dist" (copy) task
Created 699 directories, copied 1980 files

Running "cdnify:dist" (cdnify) task
Going through dist/404.html, dist/index.html to update script refs
>> No "cssmin" targets found.
Warning: Task "cssmin" failed. Use --force to continue.

Aborted due to warnings.


Execution Time (2014-02-06 19:49:33 UTC)
clean:dist           1.3s  ■■■■■■■■■■■ 8%
useminPrepare:html  169ms  ■■ 1%
concurrent:dist      5.3s  ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 33%
ngmin:dist           2.3s  ■■■■■■■■■■■■■■■■■■■ 14%
copy:dist            6.8s  ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 42%
Total 16.1s

3 个答案:

答案 0 :(得分:3)

Yeoman开箱即用的配置需要一些调整。注释时,cssmin是构建任务的一部分。由于后来列出了'usemin',我只是将其从任务中删除了。

答案 1 :(得分:1)

您需要在此应用中为构建css文件添加注释

<!-- build:css(.) styles/vendor.css -->
    <!-- Bootstrap -->
    <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">

<!-- endbuild -->
<!-- build:css(.tmp) styles/main.css -->
    <link rel="stylesheet" href="styles/styles.css">
<!-- endbuild -->

答案 2 :(得分:0)

如果你看一下Gruntfile.js,它也会在某个时刻说出这个:

// By default, your `index.html`'s <!-- Usemin block --> will take care
// of minification. These next options are pre-configured if you do not
// wish to use the Usemin blocks.

因此,您将该块保留在HTML中,或者在Gruntfile.js中取消注释!我花了一段时间来弄清楚,因为我立即清理了我的HTML,但它现在就像一个魅力!