You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
795 B
23 lines
795 B
const isWin = /^win/.test(process.platform)
|
|
const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path)
|
|
|
|
function optimizeChunk(chunk) {
|
|
if (!chunk) {
|
|
return
|
|
}
|
|
const subPackages = Object.keys(process.UNI_SUBPACKAGES).map(root => `${root}/app-sub-service`)
|
|
const chunks = Array.from(chunk.groupsIterable)[0].chunks
|
|
Array.from(chunk.groupsIterable)[0].chunks = chunks.filter(chunk => !subPackages.includes(normalizePath(chunk.id)))
|
|
}
|
|
|
|
class SubPackagesPlugin {
|
|
apply(compiler) {
|
|
compiler.hooks.thisCompilation.tap('SubPackagesPlugin', compilation => {
|
|
compilation.hooks.afterOptimizeChunkIds.tap('SubPackagesPlugin', chunks => {
|
|
optimizeChunk(chunks.find(chunk => chunk.id === 'app-service'))
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
module.exports = SubPackagesPlugin
|
|
|