Yeomen webapp generator failing on grunt build on

2020-03-31 07:21发布

I'm trying out the yeomen scaffolding tool. The only problem it that i am running into some problems with it and grunt. I’m trying to assemble a simple website using the webapp generator. Scaffolding the application and using grunt serve works perfectly. It only fails when using grunt build

It fails with this message:

Running "useminPrepare:html" (useminPrepare) task
Warning: An error occurred while processing a template (Unexpected token )). Use --force to continue.

Using force does not solve the problem. I attemted to bypass the operation in the gruntfile by removing the following line html: '<%= config.app %>/index.html' in

useminPrepare: {
  options: {
    dest: '<%= config.dist %>'
  },
  html: '<%= config.app %>/index.html'
},

It skipped the current problem without errors, but then another error occured

Warning: Running "imagemin:dist" (imagemin) task
Warning: An error occurred while processing a template (Unexpected token )). Use --force to continue.

I have scaffolded around 12 times with the same generator without any change. I have also tried using another computer with the same configuration without any change.

Git, Node, npm, grunt, bower, ruby, sass and yo is all up to date. It never stated anywhere (except in the errors) to get ruby and sass so im assuming i’m missing some other important technology too.

I am using powershell on windows 10. Tried using the git shell, but still got the same errors. Really like what yeoman has to offer. Appreciate any suggestions/solutions.

1条回答
Emotional °昔
2楼-- · 2020-03-31 08:07

I'll bet your problem is with the imagemin task.

imagemin: {
  dist: {
    files: [{
      expand: true,
      cwd: '<%= config.app %>/images',
      src: '{,*/}*.{gif,jpeg,jpg,png}',
      dest: '<%= config.dist %>/images'
    },{
      expand: true,
      cwd: '<%= config.app %%>',
      src: '*.{ico,png}',
      dest: '<%= config.dist %%>'
    }]
  }
},

Notice in the second files object, cwd and dest templates have an extra %? Get rid of them.

查看更多
登录 后发表回答