-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
113 lines (109 loc) · 2.82 KB
/
webpack.config.js
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import { resolve as _resolve } from 'path';
import TerserPlugin from 'terser-webpack-plugin';
const PATHS = {
entryPoint: './src/index.ts',
bundle: {
es5: _resolve('./dist/es5/umd'),
es6: _resolve('./dist/umd'),
},
};
const baseConfig = {
entry: {
'icon-element': [PATHS.entryPoint],
'icon-element.min': [PATHS.entryPoint],
},
output: {
filename: '[name].js',
libraryTarget: 'umd',
publicPath: '/',
},
resolve: {
extensions: ['.ts', '.tsx', '.js'],
},
devtool: 'nosources-source-map',
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
include: /\.min\.js$/,
}),
],
},
devServer: {
static: [
{
directory: _resolve('./public'),
},
{
directory: _resolve('./node_modules')
},
],
devMiddleware: {
publicPath: '/',
}
},
};
const config = [
{
...baseConfig,
name: 'es5',
output: {
...baseConfig.output,
path: PATHS.bundle.es5,
},
target: ['web', 'es5'],
module: {
rules: [
{
test: /\.tsx?$/,
use: [
{
loader: 'ts-loader',
options: {
compilerOptions: {
declaration: false,
target: 'es5',
module: 'commonjs',
lib: [
'es2015',
'dom'
],
},
}
}
],
exclude: /node_modules/,
},
],
},
},
{
...baseConfig,
name: 'es6',
output: {
...baseConfig.output,
path: PATHS.bundle.es6,
},
target: ['web', 'es6'],
module: {
rules: [
{
test: /\.tsx?$/,
use: [
{
loader: 'ts-loader',
options: {
compilerOptions: {
declaration: false,
target: 'es6',
},
}
}
],
exclude: /node_modules/,
},
],
},
}
];
export default config;