-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.ts
57 lines (54 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
import { resolve } from 'path';
import { TsconfigPathsPlugin } from 'tsconfig-paths-webpack-plugin';
import webpack from 'webpack';
import { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
const devMode = process.env.NODE_ENV === 'development';
const config: webpack.Configuration & { devServer: WebpackDevServerConfiguration } = {
mode: devMode ? 'development' : 'production',
devtool: devMode ? 'inline-source-map' : 'hidden-source-map',
entry: './src/entry.ts',
output: {
filename: 'entry.js',
path: resolve(__dirname, 'dist'),
library: 'main',
libraryTarget: 'umd',
devtoolNamespace: '',
},
resolve: {
extensions: ['.ts', '.js'],
plugins: [
new TsconfigPathsPlugin({
configFile: 'tsconfig.build.json',
}),
],
},
module: {
rules: [
{
test: /\.ts$/,
loader: 'ts-loader',
options: {
configFile: 'tsconfig.build.json',
transpileOnly: devMode,
},
},
],
},
plugins: [
new CleanWebpackPlugin(),
new webpack.SourceMapDevToolPlugin({
filename: undefined,
exclude: [/node_modules/],
test: /\.ts($|\?)/i,
}),
new HtmlWebpackPlugin(),
],
devServer: {
compress: true,
open: true,
injectClient: false, // https://github.com/webpack/webpack-dev-server/issues/2484#issuecomment-655211893
},
};
export default config;