-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
85 lines (80 loc) · 2.44 KB
/
Copy pathwebpack.config.js
File metadata and controls
85 lines (80 loc) · 2.44 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
const path = require('path');
const webpack = require('webpack');
const WebpackDashDynamicImport = require('@plotly/webpack-dash-dynamic-import');
const packagejson = require('./package.json');
const dashLibraryName = packagejson.name.replace(/-/g, '_');
module.exports = (env, argv) => {
const mode = (argv && argv.mode) || 'production';
const entry = {index: './src/lib/index.js'};
const output = {
path: path.resolve(__dirname, dashLibraryName),
filename: `${dashLibraryName}.min.js`,
library: dashLibraryName,
libraryTarget: 'window',
};
const externals = {
react: 'React',
'react-dom': 'ReactDOM',
'plotly.js': 'Plotly',
'prop-types': 'PropTypes',
};
return {
mode,
entry,
output,
externals,
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
},
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
// Fix for MUI X Charts ESM modules
{
test: /\.m?js$/,
resolve: {
fullySpecified: false,
},
},
],
},
resolve: {
extensions: ['.js', '.jsx'],
},
optimization: {
splitChunks: {
name: `${dashLibraryName}-shared`,
cacheGroups: {
async: {
chunks: 'async',
minSize: 0,
name(module, chunks, cacheGroupKey) {
return `${dashLibraryName}-${chunks[0].name}`;
},
},
shared: {
chunks: 'all',
minSize: 0,
minChunks: 2,
name: `${dashLibraryName}-shared`,
priority: -10,
},
},
},
},
plugins: [
new WebpackDashDynamicImport(),
new webpack.SourceMapDevToolPlugin({
filename: '[file].map',
exclude: /async-/,
}),
],
};
};