Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hagevvashi/ca354814fefd3ea5aa6866d92c736956 to your computer and use it in GitHub Desktop.
Save hagevvashi/ca354814fefd3ea5aa6866d92c736956 to your computer and use it in GitHub Desktop.
動的にentryを作成するサンプル
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