如何使grunt在构建时输出不同的名称[random string] .main.js?

时间:2014-01-23 19:18:17

标签: build gruntjs

两个月前,通过输出[随机字符串] .main.js(和css),grunt构建运行良好。也会用useminPrepare替换js和css块,usemin ...但是现在我不知道为什么,但构建只是一个main.js文件。设置是一样的,我也试过去一个版本,我确信gruntconfig文件输出了正确的版本,但没有运气。似乎有些东西改变了,搞砸了我的配置,这里是我的配置:https://gist.github.com/totty90/8584989

发生什么事了?谢谢你的帮助

1 个答案:

答案 0 :(得分:0)

问题很奇怪。我在运行grunt build --verbose时看到没有运行某些任务。咕噜声的任务是:

grunt.registerTask('build', [
    'clean:dist',
    'useminPrepare',
    'copy-extra-css',
    'concurrent:dist',
    'autoprefixer',
    'requirejs',
    'concat',
    'cssmin',
    // 'uglify',
    'modernizr', <-- Grunt was stopping at this (but would still run modernizer)
    'copy:dist',
    'devcode:dist',
    'rev:dist',
    'usemin'
]);

很奇怪吧?然后我已经删除了任务,也许是压倒一切,但不,咕噜不再工作了。

然后我将grunt任务名称更改为build2,现在它可以正常工作!!

grunt.registerTask('build2', [
    'clean:dist',
    'useminPrepare',
    'copy-extra-css',
    'concurrent:dist',
    'autoprefixer',
    'requirejs',
    'concat',
    'cssmin',
    // 'uglify',
    'modernizr',
    'copy:dist',
    'devcode:dist',
    'rev:dist',
    'usemin'
]);

在目前的自耕农版本中,这不再是问题了。