Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

Allow assets to be excluded #2

Closed
lettertwo opened this issue May 22, 2014 · 4 comments
Closed

Allow assets to be excluded #2

lettertwo opened this issue May 22, 2014 · 4 comments
Assignees

Comments

@lettertwo
Copy link
Owner

Conversely, maybe allow only some assets to be included.

new AppcachePlugin
  include: [
    /.*\.js$/
    /.*\.svg$/
  ]
  exclude: [
    /.*\/.js\/.map$/
    /\/thing\.js$/
    /\/icons\/.*\.svg$/
  ]
@lettertwo lettertwo self-assigned this May 22, 2014
@chiplay
Copy link

chiplay commented Jun 10, 2015

@lettertwo right now all of my sourcemap files are getting included in the manifest as part of the production build. I definitely don't want users downloading those huge files :) Would the exclude solution your proposing above by the only way to solve my issue?

@chiplay
Copy link

chiplay commented Jun 10, 2015

I'm going to go ahead and use this in a fork unless your thinking about implementing this any time soon:

// Exclude sourcemap files from manifest
if (path.extname(key) !== '.map') appCache.addAsset(key);

@chiplay
Copy link

chiplay commented Jun 10, 2015

@lettertwo well, I went ahead and took a stab at it :) I'm terrible at coffeescript and decided to pull in underscore to make it a bit easier, but feel free refactor to use if you want:

Object.keys(compilation.assets).forEach(function(key) {
    if (_.isArray(_this.include)) {
      if (_.some(_this.include, function(exp) { return exp.test(key); })) appCache.addAsset(key);
      return;
    }
    if (_.isArray(_this.exclude)) {
      if (_.every(_this.exclude, function(exp) { return !exp.test(key); })) appCache.addAsset(key);
      return;
    }
    appCache.addAsset(key);
  });

@vshjxyz
Copy link

vshjxyz commented Sep 9, 2015

Hey, check #7 out 😄

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants