-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.shared.js
36 lines (35 loc) · 924 Bytes
/
webpack.shared.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
const production = process.env.NODE_ENV === 'production';
const TerserPlugin = require('terser-webpack-plugin');
const nodeExternals = require('webpack-node-externals');
const path = require('path');
module.exports = (directory) => {
return {
entry: path.join(directory, './dist/index.js'),
output: {
filename: 'index.umd.js',
path: path.join(directory, 'dist'),
libraryTarget: 'umd'
},
externals: [
nodeExternals({ modulesDir: path.join(directory, 'node_modules') }),
nodeExternals({ modulesDir: path.join(__dirname, 'node_modules') })
],
module: {
rules: [
{
enforce: 'pre',
test: /\.js$/,
loader: 'source-map-loader'
}
]
},
resolve: {
extensions: ['.tsx', '.ts', '.js']
},
devtool: production ? 'source-map' : 'cheap-module-source-map',
mode: production ? 'production' : 'development',
optimization: {
minimizer: [new TerserPlugin()]
}
};
};