-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.ts
52 lines (50 loc) · 1.49 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
import { execSync } from "child_process";
import * as path from "path";
import { Configuration } from "webpack";
import { WebpackCompilerPlugin } from "webpack-compiler-plugin";
const entryPath = path.resolve(__dirname, "src");
const outputPath = path.resolve(__dirname, "lib");
const configuration: Configuration = {
devtool: "source-map",
entry: entryPath,
mode: "production",
module: {
rules: [
{
exclude: /(node_modules|bower_components)/,
test: /\.tsx?$/,
use: {
loader: "babel-loader",
options: {
plugins: ["@babel/plugin-proposal-class-properties"],
presets: ["@babel/preset-typescript"],
},
},
},
],
},
output: {
filename: "index.js",
libraryTarget: "commonjs",
path: outputPath,
},
plugins: [
new WebpackCompilerPlugin({
name: "Compile Types",
listeners: {
buildStart: () => {
execSync(`npm run clean`);
},
compileStart: (): void => {
execSync("npm run compile-types");
},
},
stageMessages: null,
}),
],
resolve: {
extensions: [".js", ".ts", ".d.ts"],
modules: [path.resolve("./src"), path.resolve("./node_modules")],
},
};
export default configuration;