import { resolve } from "path"; import { fileURLToPath } from "url"; import exports, { Configuration } from "webpack"; const { WatchIgnorePlugin } = exports; let dirname = fileURLToPath(new URL(".", import.meta.url)); let generator = (env: any, argv: any): Configuration[] => { return [ { target: "web", mode: env.production ? "production" : "development", entry: { main: "./src/index.ts" }, output: { filename: "[name].js", path: resolve(dirname, "lib"), devtoolFallbackModuleFilenameTemplate: "../[resource-path]", libraryTarget: "module", chunkFormat: "module", environment: { dynamicImport: true } }, devtool: "source-map", resolve: { extensions: [ ".ts", ".js" ], extensionAlias: { ".js": [ ".js", ".ts" ], ".mjs": [ ".mjs", ".mts" ], ".cjs": [ ".cjs", ".cts" ] } }, plugins: [ new WatchIgnorePlugin( { paths: [ /\.d\.ts$/ ] }) ], module: { rules: [ { test: /\.([cm]?ts|tsx)$/, exclude: /node_modules/, use: [ { loader: "ts-loader", options: { configFile: resolve(dirname, "tsconfig.build.json"), projectReferences: true, compilerOptions: { outDir: resolve(dirname, "lib", "temp") } } } ] } ] }, experiments: { outputModule: true } } ]; }; // eslint-disable-next-line import/no-default-export export default generator;