generated from iamogbz/node-js-boilerplate
-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.config.ts
63 lines (61 loc) · 1.51 KB
/
webpack.config.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
51
52
53
54
55
56
57
58
59
60
61
62
63
import { execSync } from "child_process";
import * as path from "path";
import { Configuration } from "webpack";
import { WebpackCompilerPlugin } from "webpack-compiler-plugin";
import * as nodeExternals from "webpack-node-externals";
const configuration: Configuration = {
devtool: "source-map",
entry: "./src",
mode: "production",
module: {
rules: [
{
exclude: /(node_modules|bower_components)/,
test: /\.tsx?$/,
use: [
{
loader: "babel-loader",
options: {
presets: ["@babel/preset-typescript"],
},
},
{
loader: "ts-loader",
options: {
configFile: "tsconfig.prod.json",
},
},
],
},
],
},
output: {
filename: "main.js",
libraryTarget: "commonjs",
path: path.resolve(__dirname, "lib"),
},
plugins: [
new WebpackCompilerPlugin({
name: "script-build-types",
listeners: {
compileStart: (): void => {
try {
execSync("pnpm build-types");
} catch (e) {
// eslint-disable-next-line no-console
console.error(e);
}
},
},
}),
],
resolve: {
extensions: [".js", ".ts", ".jsx", ".tsx"],
modules: [path.resolve("./src"), path.resolve("./node_modules")],
},
watchOptions: {
ignored: /node_modules|built|lib/,
},
externals: [nodeExternals()] as Configuration["externals"],
};
export default configuration;