-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathwebpack.config.ts
66 lines (56 loc) · 1.48 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
64
65
66
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import * as path from 'path';
import { Configuration, ProgressPlugin } from 'webpack';
import * as CopyWebpackPlugin from 'copy-webpack-plugin';
type Mode = 'development' | 'production';
const mode = (process.env.NODE_ENV as Mode) ?? 'development';
const isProductionMode = mode === 'production';
console.debug('*** mode', mode);
const config: Configuration = {
mode,
profile: true,
bail: isProductionMode,
devtool: 'source-map',
resolve: {
extensions: ['.ts', '.js']
},
entry: {
'prouter.min': './src/index.ts'
},
output: {
path: path.resolve('dist'),
publicPath: '/',
filename: '[name].js',
chunkFilename: '[id].chunk.js',
library: 'prouter',
libraryTarget: 'umd'
},
module: {
rules: [
/*
* Source map loader support for *.js files
* Extracts SourceMaps for source files that as added as sourceMappingURL comment.
*
* See: https://github.com/webpack/source-map-loader
*/
{
test: /\.js$/,
use: 'source-map-loader',
enforce: 'pre'
},
{
test: /\.ts$/,
loader: 'ts-loader',
exclude: /node_modules/,
options: {
configFile: 'tsconfig.build.json'
}
}
]
},
plugins: [new CopyWebpackPlugin({ patterns: ['package.json', 'README.md', 'LICENSE'] })]
};
if (isProductionMode) {
config.plugins!.unshift(new ProgressPlugin());
}
module.exports = config;