You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.6 KiB
60 lines
1.6 KiB
import plaid from '@gera2ld/plaid';
|
|
import { versionLoader } from '../../util.mjs';
|
|
import pkg from './package.json' assert { type: 'json' };
|
|
|
|
const { getRollupPlugins, defaultOptions } = plaid;
|
|
const getVersion = versionLoader(import.meta.url);
|
|
|
|
export default async () => {
|
|
const DIST = defaultOptions.distDir;
|
|
const BANNER = `/*! ${pkg.name} v${pkg.version} | ${pkg.license} License */`;
|
|
|
|
const replaceValues = {
|
|
'process.env.D3_VERSION': JSON.stringify(await getVersion('d3')),
|
|
'process.env.LIB_VERSION': JSON.stringify(await getVersion('markmap-lib')),
|
|
'process.env.VIEW_VERSION': JSON.stringify(await getVersion('markmap-view')),
|
|
'process.env.TOOLBAR_VERSION': JSON.stringify(await getVersion('markmap-toolbar')),
|
|
};
|
|
|
|
const globalList = [
|
|
];
|
|
const bundleOptions = {
|
|
extend: true,
|
|
esModule: false,
|
|
};
|
|
const rollupConfig = [
|
|
{
|
|
input: 'src/index.ts',
|
|
external: globalList,
|
|
plugins: getRollupPlugins({
|
|
esm: true,
|
|
extensions: defaultOptions.extensions,
|
|
babelConfig: {
|
|
rootMode: 'upward',
|
|
},
|
|
replaceValues,
|
|
}),
|
|
output: {
|
|
format: 'iife',
|
|
file: `${DIST}/index.js`,
|
|
name: 'markmap.autoLoader',
|
|
...bundleOptions,
|
|
},
|
|
},
|
|
];
|
|
|
|
rollupConfig.forEach((item) => {
|
|
item.output = {
|
|
indent: false,
|
|
// If set to false, circular dependencies and live bindings for external imports won't work
|
|
externalLiveBindings: false,
|
|
...item.output,
|
|
...BANNER && {
|
|
banner: BANNER,
|
|
},
|
|
};
|
|
});
|
|
|
|
return rollupConfig;
|
|
};
|