Skip to content

Instantly share code, notes, and snippets.

@MilosRasic
Created August 20, 2018 11:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MilosRasic/d37e4498ee456b0cd51ee524bfb20ae3 to your computer and use it in GitHub Desktop.
Save MilosRasic/d37e4498ee456b0cd51ee524bfb20ae3 to your computer and use it in GitHub Desktop.
GGS app cache group
const vendorChunkName = `${chunkName}.vendor`;
const appCacheGroups = {
//app code
[chunkName]: {
name: chunkName,
test: function(module) {
const include = !module.context || module.context.indexOf('node_modules') === -1;
return include;
},
},
//app dependencies
[vendorChunkName]: {
name: vendorChunkName,
test: function(module) {
if (!module.context) {
return false;
}
const modules = Object.keys(packageJson.dependencies).filter(dep => dep.indexOf(GGS_PREFIX) < 0);
const moduleNameInPathStart = module.context.lastIndexOf('node_modules') + 13;
let pathSepAfterModuleName = module.context.indexOf(path.sep, moduleNameInPathStart);
if (pathSepAfterModuleName < moduleNameInPathStart) {
pathSepAfterModuleName = undefined;
}
const moduleName = module.context.substring(moduleNameInPathStart, pathSepAfterModuleName);
if (moduleName.startsWith(GGS_PREFIX)) {
return false;
}
return modules.includes(moduleName);
},
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment