This repository was archived by the owner on Jun 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
60 lines (57 loc) · 1.43 KB
/
webpack.config.js
File metadata and controls
60 lines (57 loc) · 1.43 KB
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
const path = require('path');
const FileManagerPlugin = require('filemanager-webpack-plugin');
const webpack = require('webpack');
const { getIfUtils, removeEmpty } = require('webpack-config-utils');
const packageJson = require('./package.json');
const { ifProduction, ifNotProduction } = getIfUtils(process.env.NODE_ENV);
const destination = path.resolve(__dirname, 'dist');
module.exports = {
mode: ifProduction('production', 'development'),
watch: ifProduction(false, true),
devtool: ifProduction('source-map', 'cheap-module-eval-source-map'),
entry: {
main: './src/index.js',
...ifNotProduction({ streams: './examples/streams.js' })
},
output: {
path: destination,
filename: '[name].js',
library: packageJson.name,
libraryTarget: 'umd',
globalObject: '(self || this)'
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
babelrc: true
}
}
}
]
},
stats: {
colors: true
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
STREAM_HOST: JSON.stringify(process.env.STREAM_HOST)
}
}),
new FileManagerPlugin({
onEnd: {
copy: removeEmpty([
ifNotProduction({
source: path.resolve(__dirname, 'examples', 'index.html'),
destination
})
])
}
})
]
};