Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gruntjs 为什么我们需要使用grunt-useminPrepare_Gruntjs_Yeoman_Grunt Usemin - Fatal编程技术网

Gruntjs 为什么我们需要使用grunt-useminPrepare

Gruntjs 为什么我们需要使用grunt-useminPrepare,gruntjs,yeoman,grunt-usemin,Gruntjs,Yeoman,Grunt Usemin,我有点搞不懂为什么yeoman angular generator在useminPrepare任务中有concat任务,因为concat和uglify在构建任务的后面运行 // Reads HTML for usemin blocks to enable smart builds that automatically // concat, minify and revision files. Creates configurations in memory so // additional ta

我有点搞不懂为什么yeoman angular generator在useminPrepare任务中有concat任务,因为concat和uglify在构建任务的后面运行

// Reads HTML for usemin blocks to enable smart builds that automatically
// concat, minify and revision files. Creates configurations in memory so
// additional tasks can operate on them
useminPrepare: {
  html: '<%= yeoman.app %>/index.html',
  options: {
    dest: '<%= yeoman.dist %>',
    flow: {
      html: {
        steps: {
          js: ['concat', 'uglifyjs'],
          css: ['cssmin']
        },
        post: {}
      }
    }
  }
},



  grunt.registerTask('build', [
    'clean:dist',
    'bowerInstall',
    'useminPrepare',
    'concurrent:dist',
    'autoprefixer',
    'concat',
    'ngmin',
    'copy:dist',
    'cdnify',
    'cssmin',
    'uglify',
    'rev',
    'usemin',
    'htmlmin'
  ]);
//读取usemin块的HTML以启用自动生成的智能生成
//压缩、缩小和修订文件。在内存中创建配置,以便
//其他任务可以对它们进行操作
使用准备:{
html:“/index.html”,
选项:{
目标:'',
流量:{
html:{
步骤:{
js:['concat','uglifyjs'],
css:['cssmin']
},
职位:{}
}
}
}
},
grunt.registerTask('build'[
“清洁区”,
“鲍威尔高中”,
“使用MinPrepare”,
'并发:dist',
“自动刷新器”,
"海螺",,
"ngmin",,
'副本:dist',
“cdnify”,
“cssmin”,
"丑",,
“rev”,
“usemin”,
“htmlmin”
]);

有人能告诉我吗?

使用MinPrepare任务实际上没有进行任何缩小,而是解析HTML并为其他任务设置相应的配置。例如,如果您的HTML中有以下内容:

<!-- build:js js/app.js -->
<script src="js/app.js"></script>
<script src="js/controllers/thing-controller.js"></script>
<script src="js/models/thing-model.js"></script>
<script src="js/views/thing-view.js"></script>
<!-- endbuild -->
然后,HTML中的块将替换为:

<script src="dist/js/app.js"></script>


有关更多信息,请参阅。

cool,构建任务中的concat任务是否引用了自动生成的concat配置?
<script src="dist/js/app.js"></script>