support commonjs and mjs
This commit is contained in:
@@ -7,7 +7,7 @@ import json from '@rollup/plugin-json';
|
||||
const commonConfig = {
|
||||
input: 'src/index.js',
|
||||
output: {
|
||||
name: 'repertory-js',
|
||||
name: 'index',
|
||||
sourcemap: true,
|
||||
},
|
||||
plugins: [
|
||||
@@ -28,19 +28,33 @@ const commonConfig = {
|
||||
// ESM config
|
||||
const esmConfig = Object.assign({}, commonConfig);
|
||||
esmConfig.output = Object.assign({}, commonConfig.output, {
|
||||
file: 'dist/repertory-js.mjs',
|
||||
file: 'dist/mjs/index.js',
|
||||
format: 'esm',
|
||||
});
|
||||
|
||||
// ESM prod config
|
||||
const esmProdConfig = Object.assign({}, esmConfig);
|
||||
esmProdConfig.output = Object.assign({}, esmConfig.output, {
|
||||
file: 'dist/repertory-js.min.mjs',
|
||||
file: 'dist/mjs/index.min.js',
|
||||
sourcemap: false,
|
||||
});
|
||||
esmProdConfig.plugins = [...esmConfig.plugins, terser()];
|
||||
|
||||
// CJS config
|
||||
const cjsConfig = Object.assign({}, commonConfig);
|
||||
cjsConfig.output = Object.assign({}, commonConfig.output, {
|
||||
file: 'dist/cjs/index.js',
|
||||
format: 'cjs',
|
||||
});
|
||||
|
||||
// CJS prod config
|
||||
const cjsProdConfig = Object.assign({}, cjsConfig);
|
||||
cjsProdConfig.output = Object.assign({}, cjsConfig.output, {
|
||||
file: 'dist/cjs/index.min.js',
|
||||
sourcemap: false,
|
||||
});
|
||||
cjsProdConfig.plugins = [...cjsConfig.plugins, terser()];
|
||||
let configurations = [];
|
||||
configurations.push(esmConfig, esmProdConfig);
|
||||
configurations.push(esmConfig, esmProdConfig, cjsConfig, cjsProdConfig);
|
||||
|
||||
export default configurations;
|
||||
|
||||
Reference in New Issue
Block a user