mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
Unify webpack build
This commit is contained in:
parent
a3bda3c559
commit
e740325d84
@ -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!');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user