2 Star 0 Fork 1

mirrors_bpmn-io/properties-panel

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
rollup.config.js 1.95 KB
一键复制 编辑 原始数据 按行查看 历史
import path, { parse as parsePath, relative as relativePath } from 'path';
import { replaceInFile } from 'replace-in-file';
import babel from '@rollup/plugin-babel';
import copy from 'rollup-plugin-copy';
import json from '@rollup/plugin-json';
import resolve from '@rollup/plugin-node-resolve';
import pkg from './package.json';
import babelConfig from './.babelrc.json';
const nonbundledDependencies = Object.keys({ ...pkg.dependencies });
export default [
{
input: 'src/index.js',
output: [
{
sourcemap: true,
format: 'commonjs',
file: pkg.main
},
{
sourcemap: true,
format: 'esm',
file: pkg.module
}
],
external: [
...nonbundledDependencies,
// exclude local preact copy to share it with extensions
/\.\/preact/
],
plugins: [
copy({
// hook name provided to make sure next plugin has files to replace
hook: 'buildStart',
targets: [
{ src: 'node_modules/preact', dest: '.' },
{ src: 'src/assets', dest: 'dist' }
]
}),
rewirePreactSubpackages(),
babel({ ...babelConfig, babelHelpers: 'bundled' }),
json(),
resolve()
]
}
];
/**
* Monkey-patch preact subpackages to import from the local package via relative path.
*/
function rewirePreactSubpackages() {
return {
async buildEnd() {
await replaceInFile({
files: './preact/**/*.{js,mjs,js.map}',
from: [ /(import\s*['"])preact([/'"])/g, /(from\s*['"])preact([/'"])/g, /(require\(['"])preact([/'"])/g ],
to: function(...args) {
const importGroup = args[1],
afterImport = args[2],
filePath = args.pop();
const { dir } = parsePath(filePath);
const posixPathToPreact = relativePath(dir, './preact').split(path.sep).join(path.posix.sep);
return `${importGroup}${posixPathToPreact}${afterImport}`;
}
});
}
};
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_bpmn-io/properties-panel.git
git@gitee.com:mirrors_bpmn-io/properties-panel.git
mirrors_bpmn-io
properties-panel
properties-panel
main

搜索帮助

0d507c66 1850385 C8b1a773 1850385