Grunt 构建在 Yo Angular 中不起作用

2024-03-21

我用 Yo 角度生成器构建了一个 Angular 应用程序,

我正在使用 Grunt Build 构建应用程序,然后添加了 Bootstrap 3 以及 npm install grunt-bower-install

我将这些行添加到 Grunt 文件中

module.exports = function (grunt) {


  require('load-grunt-tasks')(grunt);

  require('time-grunt')(grunt);

  //ADDED THIS LINE
  grunt.loadNpmTasks('grunt-bower-install');

  grunt.initConfig({

    yeoman: {
      // configurable paths
      app: require('./bower.json').appPath || 'app',
      dist: 'dist'
    },
     //ADDED THESE LINES
    'bower-install': {
        target: {
            src: [
              'app/index.html'
            ],

          }
        },

不过我已经删除了这些行!

现在 Grunt Build 抛出这个错误

Running "bowerInstall:app" (bowerInstall) task
Warning: Cannot read property 'main' of undefined Use --force to continue.

Aborted due to warnings.

我确实知道该做什么,甚至知道从哪里开始?


在我的 yeoman 生成的项目中,此任务如下所示:

'bower-install': {
  app: {
    html: '<%= yeoman.app %>/index.html',
    ignorePath: '<%= yeoman.app %>/'
  }
},

在新版本中而不是html uses src:

'bowerInstall': {
  app: {
    src: ['<%= yeoman.app %>/index.html'],
    ignorePath: '<%= yeoman.app %>/'
  }
},

也许您可以根据您的情况进行调整。尽管我认为它应该无需更改即可工作。

但你的情况几乎一样,所以也许问题在另一个地方。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Grunt 构建在 Yo Angular 中不起作用 的相关文章

随机推荐