Ember-cli如何更改文件的输入路径

Ember-cli how to change input path of files

我是 ember 的新手。但是对于特定任务,我需要更改模板的输入路径以进行编译。即默认值为 app/templates。但我想改变这条路。 我已阅读 ember-cli-build.js 文件,但我只能编辑输出路径。我如何编辑输入路径。 我的 ember-cli-build.js

var EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function(defaults) {
  var app = new EmberApp(defaults, {
    // Add options here
    outputPaths: {
      app: {
        html: 'ember_build_index.html'
      }
    }
  });

  // Use `app.import` to add additional libraries to the generated
  // output files.
  //
  // If you need to use different assets in different
  // environments, specify an object as the first parameter. That
  // object's keys should be the environment name and the values
  // should be the asset to use in that environment.
  //
  // If the library that you are including contains AMD or ES6
  // modules that you would like to import into your application
  // please specify an object with the list of modules as keys
  // along with the exports of each module as its value.

app.import('bower_components/bootstrap/dist/js/bootstrap.min.js');
app.import('bower_components/bootstrap/dist/css/bootstrap.min.css');
app.import('bower_components/bootstrap/dist/css/bootstrap.css.map');
  return app.toTree();
};

您必须更改正在构建的 ember 应用程序的模板目录路径。

要检查您当前的模板目录路径,请使用 console.log(app.trees.templates._directoryPath) .

现在,如果您希望 ember 构建具有来自 'app/templates/mobile' 的模板(在您的情况下),只需更改: app.trees.templates._directoryPath = 'app/templates/mobile' 在 ember-cli-build.js 之前 returns app.toTree();

为模板构建树的node_module在'node_modules/ember-cli/lib/broccoli/ember-app.js'第1行。 724 它访问 'this.trees.templates' 其中这是您的应用程序的实例。