Created
May 27, 2021 07:47
-
-
Save mpg-tomoya-komiyama/f2a06cba2dfe4f6a9ecd1395ca2ea97c to your computer and use it in GitHub Desktop.
webpack config for grouping multi entries
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 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