mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-23 18:21:50 +03:00
2f6c4e3696
Co-authored-by: Hongtao Lye <codert.sn@gmail.com> Co-authored-by: liuyi <forehalo@gmail.com> Co-authored-by: LongYinan <lynweklm@gmail.com> Co-authored-by: X1a0t <405028157@qq.com> Co-authored-by: JimmFly <yangjinfei001@gmail.com> Co-authored-by: Peng Xiao <pengxiao@outlook.com> Co-authored-by: xiaodong zuo <53252747+zuoxiaodong0815@users.noreply.github.com> Co-authored-by: DarkSky <25152247+darkskygit@users.noreply.github.com> Co-authored-by: Qi <474021214@qq.com> Co-authored-by: danielchim <kahungchim@gmail.com>
87 lines
2.2 KiB
TypeScript
87 lines
2.2 KiB
TypeScript
function testPackageName(regexp: RegExp): (module: any) => boolean {
|
|
return (module: any) =>
|
|
module.nameForCondition && regexp.test(module.nameForCondition());
|
|
}
|
|
|
|
// https://hackernoon.com/the-100-correct-way-to-split-your-chunks-with-webpack-f8a9df5b7758
|
|
export const productionCacheGroups = {
|
|
asyncVendor: {
|
|
test: /[\\/]node_modules[\\/]/,
|
|
name(module: any) {
|
|
// monorepo linked in node_modules, so it's not a npm package
|
|
if (!module.context.includes('node_modules')) {
|
|
return `app-async`;
|
|
}
|
|
const name = module.context.match(
|
|
/[\\/]node_modules[\\/](.*?)([\\/]|$)/
|
|
)?.[1];
|
|
return `npm-async-${name}`;
|
|
},
|
|
priority: Number.MAX_SAFE_INTEGER,
|
|
chunks: 'async' as const,
|
|
},
|
|
mui: {
|
|
name: `npm-mui`,
|
|
test: testPackageName(/[\\/]node_modules[\\/](mui|@mui)[\\/]/),
|
|
priority: 200,
|
|
enforce: true,
|
|
},
|
|
blocksuite: {
|
|
name: `npm-blocksuite`,
|
|
test: testPackageName(/[\\/]node_modules[\\/](@blocksuite)[\\/]/),
|
|
priority: 200,
|
|
enforce: true,
|
|
},
|
|
react: {
|
|
name: `npm-react`,
|
|
test: testPackageName(
|
|
/[\\/]node_modules[\\/](react|react-dom|scheduler)[\\/]/
|
|
),
|
|
priority: 200,
|
|
enforce: true,
|
|
},
|
|
jotai: {
|
|
name: `npm-jotai`,
|
|
test: testPackageName(/[\\/]node_modules[\\/](jotai)[\\/]/),
|
|
priority: 200,
|
|
enforce: true,
|
|
},
|
|
rxjs: {
|
|
name: `npm-rxjs`,
|
|
test: testPackageName(/[\\/]node_modules[\\/]rxjs[\\/]/),
|
|
priority: 200,
|
|
enforce: true,
|
|
},
|
|
lodash: {
|
|
name: `npm-lodash`,
|
|
test: testPackageName(/[\\/]node_modules[\\/]lodash[\\/]/),
|
|
priority: 200,
|
|
enforce: true,
|
|
},
|
|
emotion: {
|
|
name: `npm-emotion`,
|
|
test: testPackageName(/[\\/]node_modules[\\/](@emotion)[\\/]/),
|
|
priority: 200,
|
|
enforce: true,
|
|
},
|
|
vendor: {
|
|
name: 'vendor',
|
|
test: /[\\/]node_modules[\\/]/,
|
|
priority: 190,
|
|
enforce: true,
|
|
},
|
|
styles: {
|
|
name: 'styles',
|
|
test: (module: any) =>
|
|
module.nameForCondition &&
|
|
/\.css$/.test(module.nameForCondition()) &&
|
|
!/^javascript/.test(module.type),
|
|
chunks: 'all' as const,
|
|
minSize: 1,
|
|
minChunks: 1,
|
|
reuseExistingChunk: true,
|
|
priority: 1000,
|
|
enforce: true,
|
|
},
|
|
};
|