Initial commit
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
const path = require('path');
|
||||
|
||||
const configs = {
|
||||
cjs: {
|
||||
output: {
|
||||
path: path.resolve(__dirname, 'dist'),
|
||||
filename: 'windychen-utils.cjs.js',
|
||||
libraryTarget: 'commonjs2',
|
||||
},
|
||||
},
|
||||
esm: {
|
||||
experiments: { outputModule: true },
|
||||
output: {
|
||||
path: path.resolve(__dirname, 'dist'),
|
||||
filename: 'windychen-utils.esm.js',
|
||||
libraryTarget: 'module',
|
||||
},
|
||||
},
|
||||
umd: {
|
||||
output: {
|
||||
path: path.resolve(__dirname, 'dist'),
|
||||
filename: 'windychen-utils.js',
|
||||
library: { name: 'WindychenUtils', type: 'umd', export: 'default' },
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = (env = {}) => {
|
||||
const format = env.format;
|
||||
|
||||
if (!format || format === 'all') {
|
||||
return Object.keys(configs).map((key) => ({
|
||||
name: key,
|
||||
entry: './index.js',
|
||||
...configs[key],
|
||||
}));
|
||||
}
|
||||
|
||||
if (!configs[format]) {
|
||||
throw new Error(`不支持的格式: ${format},可选值: cjs, esm, umd`);
|
||||
}
|
||||
|
||||
return { entry: './index.js', ...configs[format] };
|
||||
};
|
||||
Reference in New Issue
Block a user