Created
August 20, 2018 11:48
-
-
Save MilosRasic/d37e4498ee456b0cd51ee524bfb20ae3 to your computer and use it in GitHub Desktop.
GGS app cache group
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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