2021-12-11 12:02:39 +01:00
|
|
|
import { merge, mergeWithCustomize, customizeObject } from 'webpack-merge';
|
|
|
|
import nodeExternals from 'webpack-node-externals';
|
|
|
|
import baseConfig from './webpack.config.base';
|
|
|
|
|
|
|
|
export default (_env, args) => {
|
2022-09-12 11:41:26 +05:30
|
|
|
return [
|
|
|
|
// non-minified
|
2022-09-12 11:55:40 +05:30
|
|
|
merge(baseConfig, {
|
|
|
|
optimization: {
|
|
|
|
minimize: false,
|
|
|
|
},
|
|
|
|
}),
|
2022-09-12 11:41:26 +05:30
|
|
|
// core [To be used by webpack/esbuild/vite etc to bundle mermaid]
|
|
|
|
merge(baseConfig, {
|
|
|
|
externals: [nodeExternals()],
|
|
|
|
output: {
|
|
|
|
filename: '[name].core.js',
|
|
|
|
},
|
2022-09-12 11:55:40 +05:30
|
|
|
optimization: {
|
|
|
|
minimize: false,
|
|
|
|
},
|
2022-09-12 11:41:26 +05:30
|
|
|
}),
|
|
|
|
// umd
|
|
|
|
merge(baseConfig, {
|
|
|
|
output: {
|
|
|
|
filename: '[name].min.js',
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
// esm
|
|
|
|
mergeWithCustomize({
|
|
|
|
customizeObject: customizeObject({
|
|
|
|
'output.library': 'replace',
|
|
|
|
}),
|
|
|
|
})(baseConfig, {
|
|
|
|
experiments: {
|
|
|
|
outputModule: true,
|
|
|
|
},
|
|
|
|
output: {
|
|
|
|
library: {
|
|
|
|
type: 'module',
|
|
|
|
},
|
|
|
|
filename: '[name].esm.min.mjs',
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
];
|
2021-12-11 12:02:39 +01:00
|
|
|
};
|