简体   繁体   中英

Exclude files from broccoli Ember 2.0

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');

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']

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'
    ]
  }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM