Grunt usemin问题:无法处理task.required配置属性concat.generated missing

时间:2015-05-22 11:54:20

标签: gruntjs grunt-usemin

我有像这样的文件夹结构

app
|
+- html
|   +- index.html
+- assets
|   +- js
|      +- foo.js
|      +- bar.js
+- dist

我的Gruntfile.js是

module.exports = function (grunt) {
  grunt.initConfig({
    config: {
      app: 'app',
      dist: 'dist'
    },
    useminPrepare: {
      html: 'html/index.html',
      options: {
        root: '<%= config.app %>',
        dest: '<%= config.dist %>'
      }
    },
    usemin: {
      html: ['<%= config.dist %>/html/index.html'],
      js: '<%= config.dist %>/assets/js/*.js'
    }
  });

  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-rev');
  grunt.loadNpmTasks('grunt-usemin');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.loadNpmTasks('grunt-contrib-uglify'); 

  grunt.registerTask('build', [
     'useminPrepare',
     'concat:generated',
     'cssmin:generated',
     'uglify:generated',
     'usemin'
  ]);
};

在html / index.html

<!-- build:js /assets/js/optimized.js -->
<script src="/assets/js/foo.js"></script>
<script src="/assets/js/bar.js"></script>
<!-- endbuild -->

当我执行&#39; grunt build&#39;命令,它显示&#34;无法处理task.required配置属性concat.generated missing&#34;错误。 可能是什么原因?

1 个答案:

答案 0 :(得分:1)

如果您的Gruntfile.js位于根位置,则useminPrepare任务中的html路径错误。我不确定useminPrepare是否理解'root'选项。试试这个:

m = np.memmap('train_data_features_dense.mmap', dtype=train_data_features.dtype, mode='w+', shape=train_data_features.shape)
train_data_features.todense(out=m)
# Some work with m here, if you want, reading, writing, etc
# Better to call delete when you've done all work with it, del will flush buffers automatically
del m
# If you want to load memmap in another script
m = np.memmap('train_data_features_dense.mmap', dtype=train_data_features.dtype, mode='r+', shape=train_data_features.shape)