Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
webpack config for grouping multi entries
const common = (env) => ({ /* 共通設定 */ })
const packsPath = path.join(__dirname, "app", "javascript", "packs")
const entryTypes = {
root: "*.ts",
customer: "customers/**/*.ts",
admin: "admin/**/*.ts",
}
module.exports = Object.keys(entryTypes).map((key) => (env) => ({
...common(env),
entry: glob.sync(`${packsPath}/${entryTypes[key]}`).reduce((p, filePath) => {
p[path.relative(packsPath, filePath).replace(".ts", "")] = path.resolve(__dirname, filePath)
return p
}, {}),
optimization: {
splitChunks: {
name: `vendor-${key}`,
chunks: "initial",
minChunks: 3,
},
},
}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment