【问题标题】:Grunt creating file with random number in the file name?Grunt 创建文件名中带有随机数的文件?
【发布时间】:2016-07-23 11:53:47
【问题描述】:

我使用 yeoman 创建了一个 Angular 项目。当我构建时,在 dist 文件夹中创建了 app.js 文件,但文件名是 app.js,但它是 app.2bf032ifs.js 不知道为什么?

下面是我写 uglify 的方法 -

uglify: {
     build: {
         src: '<%= yeoman.app %>/scripts/**/*.js',
         dest: '<%= yeoman.dist %>/scripts/app.js'
}
},

运行 Grunt 命令时,我收到消息

Running "ngtemplates:dist" (ngtemplates) task
File .tmp/templateCache.js created.
>> Usemin has not created uglify.generated yet!

1) 我不知道如何在 dist 文件夹中获取正确的文件名,如何? 2)如何摆脱上述消息? 3) 文件名,在生成最终的 css 文件时也有类似的行为。

注意 - 下面是我的 usemin 任务

usemin: {
  html: ['<%= yeoman.dist %>/{,*/}*.html'],
  css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
  js: ['<%= yeoman.dist %>/scripts/{,*/}*.js'],
  options: {
    assetsDirs: [
      '<%= yeoman.dist %>',
      '<%= yeoman.dist %>/images',
      '<%= yeoman.dist %>/styles'
    ],
    patterns: {
      js: [[/(images\/[^''""]*\.(png|jpg|jpeg|gif|webp|svg))/g, 'Replacing references to images']]
    }
  }
},

【问题讨论】:

    标签: angularjs gruntjs yeoman minify uglifyjs


    【解决方案1】:

    这是由于名为“filerev”的任务而发生的,该策略用于告诉浏览器每次都下载文件的新副本,以便它不被缓存。如果您不希望它发生,请评论任务“filerev”。

    类似:

    grunt.registerTask('build', [
    'clean:dist',
    'wiredep',
    'useminPrepare',
    'concurrent:dist',
    'postcss',
    'ngtemplates',
    'concat',
    'ngAnnotate',
    'copy:dist',
    'cdnify',
    'cssmin',
    'uglify',
    //'filerev',
    'usemin',
    'htmlmin'
    

    ]);

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多