-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwebpack.config.cjs
More file actions
88 lines (87 loc) · 2.82 KB
/
webpack.config.cjs
File metadata and controls
88 lines (87 loc) · 2.82 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
85
86
87
88
const path = require('path');
const { version } = require('./package.json');
const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');
module.exports = (env, argv) => {
const isDevelopment = argv.mode === 'development';
return {
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
mangle: {
// This ensures class names are preserved.
keep_classnames: true,
},
keep_fnames: true,
},
}),
],
},
entry: './src/index.js',
devtool: isDevelopment ? 'source-map' : false,
experiments: {
outputModule: true
},
plugins: [
new webpack.DefinePlugin({
'process.env.VERSION': JSON.stringify(version)
})
],
watchOptions: {
ignored: /node_modules/,
aggregateTimeout: 600, // Process changes only every 600ms
poll: 1000 // Check for changes every second
},
output: {
filename: 'graphs-renderer.js',
// eslint-disable-next-line no-undef
path: path.resolve(__dirname, 'dist'),
// library: 'graphs-renderer',
libraryTarget: 'module',
},
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
},
},
},
{
test: require.resolve('d3'),
use: {
loader: 'imports-loader',
options: {
additionalCode: 'var thisObj = window;'
},
},
},
{
test: /\.css$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
modules: {
localIdentName: '[name]__[local]--[hash:base64:5]'
}
}
}
]
},
{
test: /\.css$/,
exclude: /\.module\.css$/,
use: ['style-loader', 'css-loader']
}
],
},
};
};