-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathwebpack.config.js
More file actions
84 lines (82 loc) · 2.22 KB
/
webpack.config.js
File metadata and controls
84 lines (82 loc) · 2.22 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* eslint-disable */
'use strict'
const path = require('path')
const TerserPlugin = require('terser-webpack-plugin')
const isProduction = process.env.NODE_ENV === 'production'
const envName = isProduction ? 'production' : 'development'
module.exports = {
bail: isProduction,
mode: envName,
devtool: isProduction ? 'source-map' : 'cheap-module-source-map',
entry: [path.join(__dirname, `src`, 'index.ts')],
output: {
path: path.join(__dirname, `dist/`),
filename: `erebos.swarm.${envName}.js`,
sourceMapFilename: `erebos.swarm.${envName}.js.map`,
library: ['Erebos', 'swarm'],
libraryTarget: 'umd',
devtoolModuleFilenameTemplate: info => {
return path.resolve(info.absoluteResourcePath).replace(/\\/g, '/')
},
},
module: {
rules: [
{
test: /\.(ts|js)$/,
include: path.join(__dirname, `src/`),
use: {
loader: 'babel-loader',
},
},
],
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.json'],
},
optimization: {
minimize: isProduction,
minimizer: [
// This is only used in production mode
new TerserPlugin({
terserOptions: {
parse: {
// we want terser to parse ecma 8 code. However, we don't want it
// to apply any minfication steps that turns valid ecma 5 code
// into invalid ecma 5 code. This is why the 'compress' and 'output'
// sections only apply transformations that are ecma 5 safe
// https://github.com/facebook/create-react-app/pull/4234
ecma: 8,
},
compress: {
ecma: 5,
warnings: false,
},
mangle: {
safari10: true,
},
output: {
ecma: 5,
comments: false,
},
},
// Use multi-process parallel running to improve the build speed
// Default number of concurrent runs: os.cpus().length - 1
parallel: true,
// Enable file caching
cache: true,
sourceMap: true,
}),
],
},
target: 'web',
node: {
console: false,
global: true,
process: true,
Buffer: true,
},
performance: {
hints: false,
},
stats: 'minimal',
}