EmberJS:排除监视文件夹的更改

时间:2018-10-03 15:29:22

标签: ember.js ember-cli broccolijs

如何从Ember CLI中监视特定文件夹?

1 个答案:

答案 0 :(得分:0)

这是我的ember-cli-build.js文件,其中进行了必要的更改,以取消监视“公共”目录。

const EmberApp = require('ember-cli/lib/broccoli/ember-app'),
  ENV = require('./config/environment')(process.env.EMBER_ENV),
  Funnel = require('broccoli-funnel'),
  dependencies = require('./config/dependencies'),
  UnwatchedDir = require('broccoli-source').UnwatchedDir;

module.exports = function (defaults) {
  const app = new EmberApp(defaults, ENV.options),
    imports = dependencies.imports;

  for (let i = 0; i < imports.length; i++) {
    app.import(imports[i]);
  }

  const compilationAssets = [],
    funnels = dependencies.funnels;

  Object.keys(funnels).forEach(function (key) {
    const options = funnels[key],
      funnelObj = new Funnel(key, options);

    compilationAssets.push(funnelObj);
  });

  // This does the magic
  if (process.env.EMBER_ENV === 'development' || process.env.EMBER_ENV == 'test') {
    app.trees.public = new UnwatchedDir('public');
  }

  return app.toTree(compilationAssets);
};