-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.ts
52 lines (50 loc) · 1.34 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
const path = require('path');
const nodeExternals = require('webpack-node-externals');
const CopyPlugin = require("copy-webpack-plugin");
const WebpackShellPluginNext = require('webpack-shell-plugin-next');
const {
NODE_ENV = 'production',
} = process.env;
module.exports = {
entry: './src/index.ts',
mode: NODE_ENV,
watch: NODE_ENV == "development",
plugins: [
new CopyPlugin({
patterns: [
{ from: `.env.${NODE_ENV}` },
...(NODE_ENV === 'development' ? [{ from: `.env.local` }] : []),
{ from: `package.json` },
],
}),
...(NODE_ENV == "development" ?
[new WebpackShellPluginNext({
onBuildEnd: {
scripts: ['nodemon build'],
blocking: false,
parallel: true
}
})] :
[]
)
],
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.ts', '.js'],
},
externals: [nodeExternals()],
output: {
filename: 'index.js',
path: path.resolve(__dirname, 'build'),
libraryTarget: 'umd',
globalObject: 'this',
},
};