Last active
November 30, 2020 14:01
-
-
Save hagevvashi/ca354814fefd3ea5aa6866d92c736956 to your computer and use it in GitHub Desktop.
動的にentryを作成するサンプル
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
import { Configuration } from "webpack"; | |
import glob from "glob"; | |
const entries: string[] = glob.sync( | |
"src/path/**/*.t+(s|x)" | |
); | |
const chunks = entries.map((entry) => [ | |
entry.replace(/^src\/path\//, "").replace(/\.tsx?$/, ""), | |
`./${entry}`, | |
]); | |
const config: Configuration = { | |
entry: Object.fromEntries( | |
chunks.map(([chunk, entry]) => { | |
return [ | |
chunk, | |
[ | |
"./node_modules/some-polyfill-package/index.js" | |
`./${entry}`, | |
], | |
]; | |
}) | |
), | |
} | |
export default config; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment