访问 yeoman 项目中的根文件夹给出 404,但 bower_components 不是

Accessing root folder in yeoman project gives 404, but bower_components is not

我刚刚使用 yeoman angular 生成器创建了 Web 项目。我注意到 bower_components 在根文件夹中。我想将未使用 bower 安装的其他组件放入 not_bower_components 文件夹(也在根文件夹中)。问题是当我 运行 g运行t 服务时它给了我 404,但是 bower_components 中的所有文件都没有 return 404。我该如何解决这个问题?

angular 生成器生成的 Gruntfile 使用 connect for the http server, the generator also attaches a plugin to the server called livereload which magically injects new code or reloads the page (depending on the extension of the file modified), theseGruntfile.js 文件的默认选项,我认为您必须更新中间件功能才能同时考虑您的 not_bower_components文件夹:

livereload: {
  options: {
    open: true,
    middleware: function (connect) {
      return [
        connect.static('.tmp'),
        connect().use(
          '/bower_components',
          connect.static('./bower_components')
        ),
        connect().use(
          '/not_bower_components',
          connect.static('./not_bower_components')
        ),
        connect().use(
          '/app/styles',
          connect.static('./app/styles')
        ),
        connect.static(appConfig.app)
      ];
    }
  }
}