ConnectForce/webpack.config.ts
Manuel Thalmann a409ebb160
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Compile mocha test files
2022-12-02 01:11:30 +01:00

92 lines
2.7 KiB
TypeScript

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",
...(
env.production ?
{} :
{
"tests/main.test": "./src/tests/main.test.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;