-
Notifications
You must be signed in to change notification settings - Fork 18
/
webpack.build.config.js
58 lines (55 loc) · 1.06 KB
/
webpack.build.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
const webpack = require('webpack');
const path = require('path');
const isProd = process.env.NODE_ENV === 'production';
const envPlugin = new webpack.EnvironmentPlugin({
NODE_ENV: 'development',
});
const rules = [
{
test: /\.tsx?$/,
exclude: [/(node_modules|.webpack)/],
rules: [
{
loader: 'ts-loader',
options: {
configFile: 'tsconfig.json',
transpileOnly: true,
},
},
],
},
{
test: /\.node$/,
use: 'node-loader',
},
];
module.exports = [
{
mode: isProd ? 'production' : 'development',
entry: {
lib: path.join(__dirname, 'src', 'lib.ts'),
},
target: 'webworker',
devtool: 'source-map',
resolve: {
extensions: ['.ts', '.js'],
},
node: {
__dirname: true,
},
module: {
rules: [...rules],
},
output: {
publicPath: '',
path: __dirname + '/build',
filename: `[name].js`,
libraryTarget: 'umd',
globalObject: 'this',
umdNamedDefine: true,
},
plugins: [
envPlugin,
],
},
];