/
webpack.config.base.ts
50 lines (47 loc) · 1.28 KB
/
webpack.config.base.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import type { Configuration } from "webpack";
import * as path from "node:path";
// @ts-expect-error: This is only complaining on the editor, using webpack works
// as expected.
import LicensePlugin from "webpack-license-plugin";
import TerserPlugin from "terser-webpack-plugin";
import { TsconfigPathsPlugin } from "tsconfig-paths-webpack-plugin";
const tsconfigFile = path.resolve(process.cwd(), "tsconfig.build.json");
const config: Configuration = {
entry: "./src/index.ts",
target: "node",
mode: "production",
devtool: "source-map",
module: {
rules: [
{
test: /\.ts$/,
loader: "ts-loader",
options: {
transpileOnly: true,
configFile: tsconfigFile,
},
exclude: /node_modules/,
},
],
},
resolve: {
extensions: [".ts", ".js", ".json"],
plugins: [new TsconfigPathsPlugin({ configFile: tsconfigFile })],
},
output: {
path: path.resolve(process.cwd(), "bundle"),
filename: "index.js",
},
optimization: {
minimize: true,
usedExports: true,
minimizer: [
new TerserPlugin({
terserOptions: { format: { comments: false } },
extractComments: false,
}),
],
},
plugins: [new LicensePlugin({ outputFilename: "licenses.json" })],
};
export default config;