Exclude files from broccoli Ember 2.0

一世执手 提交于 2020-01-06 20:17:41

问题


Hi im kind of new to ember, im looking for a way to tell broccoli not to include my img/ directory, i want to include some default images there which ill be programatically adding to the app

<img src='{{model.picture}}'/>

And i can see them ok in development but not in production since the name has a hash attaches due to brocolli task, how do i configure my BrocFile to exclude files in the directory i have checked the documentation here

https://github.com/rickharrison/broccoli-asset-rev

but i cant figure out where in my brocfile im expected to add that.

part of my brocfile

var EmberApp = require('ember-cli/lib/broccoli/ember-app');
    var app = new EmberApp({
        modals: {
            layout: true,
            style: true,
            animation: 'scale'
        }
    });



    app.import({
        production: 'bower_components/raygun4js/dist/raygun.js'
    });
    app.import('bower_components/lodash/lodash.js');

回答1:


Since you are using Ember (and Ember-CLI), just make sure to scroll down far enough in the broccoli-asset-rev documentation that you linked and you will reach the part most relevant to your circumstance. In particular, the provided 'Ember CLI addon usage' example should already be a close match for your case.

Adapting that to your stated problem and provided code, you would perhaps get something along the lines of

var app = new EmberApp({
    fingerprint: {
        exclude: ['img/']
    },
    modals: {
        layout: true,
        style: true,
        animation: 'scale'
    }
});

The relevant Ember-CLI documentation section also explains fingerprinting in slightly more detail.

Other than using the exclude option, you could

  • set enabled: false if you don't actually need fingerprinting
  • not include image extensions in general via something like extensions: ['js', 'css', 'map']



回答2:


This answer applies for Ember 2.x through at least 3.x.

Another approach is to use an addon that helps you easily exclude files. Installing ember-cli-funnel and then specifying the file accomplishes this pretty nicely:

// ember-cli-build.js

let app = new EmberApp(defaults, {
  funnel: {
    exclude: [
      `${defaults.project.pkg.name}/routes/style-guide/**/*`,
      'addon-tree-output/some-addon/styles/**/*.scss'
    ]
  }
});


来源:https://stackoverflow.com/questions/33111124/exclude-files-from-broccoli-ember-2-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!