Unify webpack build

This commit is contained in:
Sidharth Vinod 2022-09-12 11:41:26 +05:30
parent a3bda3c559
commit e740325d84
No known key found for this signature in database
GPG Key ID: FB5CCD378D3907CD

View File

@ -3,43 +3,37 @@ import nodeExternals from 'webpack-node-externals';
import baseConfig from './webpack.config.base'; import baseConfig from './webpack.config.base';
export default (_env, args) => { export default (_env, args) => {
switch (args.mode) { return [
case 'development': // non-minified
return [ baseConfig,
baseConfig, // core [To be used by webpack/esbuild/vite etc to bundle mermaid]
merge(baseConfig, { merge(baseConfig, {
externals: [nodeExternals()], externals: [nodeExternals()],
output: { output: {
filename: '[name].core.js', filename: '[name].core.js',
}, },
}), }),
]; // umd
case 'production': merge(baseConfig, {
return [ output: {
// umd filename: '[name].min.js',
merge(baseConfig, { },
output: { }),
filename: '[name].min.js', // esm
}, mergeWithCustomize({
}), customizeObject: customizeObject({
// esm 'output.library': 'replace',
mergeWithCustomize({ }),
customizeObject: customizeObject({ })(baseConfig, {
'output.library': 'replace', experiments: {
}), outputModule: true,
})(baseConfig, { },
experiments: { output: {
outputModule: true, library: {
}, type: 'module',
output: { },
library: { filename: '[name].esm.min.mjs',
type: 'module', },
}, }),
filename: '[name].esm.min.mjs', ];
},
}),
];
default:
throw new Error('No matching configuration was found!');
}
}; };