修复:插件面板实例级 i18n / undo-redo 滚动保持 / shortcutHelp 卸载残留 / CSS.escape 环境崩溃 / 大纲光标按源码行号定位 / setLocale 即时刷新 / 浮动工具栏 CJK 宽度 / ko 语言包括号 新增:setOutline(isOutline) 运行时大纲 API、getRenderCacheSize 观测接口 测试:841 → 871(补 7 个事件断言、5 个配置项、修 3 处恒真断言) 工程:CI lint 阻断、build.sh npm ci、rollup 死代码清理、覆盖率阈值门禁
105 lines
2.2 KiB
JavaScript
105 lines
2.2 KiB
JavaScript
import resolve from '@rollup/plugin-node-resolve';
|
|
import commonjs from '@rollup/plugin-commonjs';
|
|
import terser from '@rollup/plugin-terser';
|
|
import typescript from '@rollup/plugin-typescript';
|
|
import dts from 'rollup-plugin-dts';
|
|
import serve from 'rollup-plugin-serve';
|
|
import livereload from 'rollup-plugin-livereload';
|
|
|
|
const isDev = process.env.ROLLUP_WATCH;
|
|
|
|
const basePlugins = [
|
|
resolve(),
|
|
commonjs(),
|
|
typescript({
|
|
tsconfig: './tsconfig.json',
|
|
declaration: false,
|
|
}),
|
|
];
|
|
|
|
const devPlugins = isDev ? [
|
|
serve({
|
|
open: true,
|
|
contentBase: ['site', 'dist'],
|
|
port: 3001,
|
|
}),
|
|
livereload({
|
|
watch: ['src', 'site'],
|
|
}),
|
|
] : [];
|
|
|
|
export default [
|
|
// UMD development
|
|
{
|
|
input: 'src/index.ts',
|
|
output: {
|
|
file: 'dist/metona-editor.js',
|
|
format: 'umd',
|
|
name: 'MeEditor',
|
|
exports: 'named',
|
|
sourcemap: true,
|
|
},
|
|
plugins: [...basePlugins, ...devPlugins],
|
|
},
|
|
// Only build all formats in production
|
|
...(isDev ? [] : [
|
|
// ES Module
|
|
{
|
|
input: 'src/index.ts',
|
|
output: {
|
|
file: 'dist/metona-editor.mjs',
|
|
format: 'es',
|
|
exports: 'named',
|
|
sourcemap: true,
|
|
},
|
|
plugins: basePlugins,
|
|
},
|
|
// CommonJS
|
|
{
|
|
input: 'src/index.ts',
|
|
output: {
|
|
file: 'dist/metona-editor.cjs',
|
|
format: 'cjs',
|
|
exports: 'named',
|
|
sourcemap: true,
|
|
},
|
|
plugins: basePlugins,
|
|
},
|
|
// UMD minified
|
|
{
|
|
input: 'src/index.ts',
|
|
output: {
|
|
file: 'dist/metona-editor.min.js',
|
|
format: 'umd',
|
|
name: 'MeEditor',
|
|
exports: 'named',
|
|
sourcemap: false,
|
|
},
|
|
plugins: [
|
|
...basePlugins,
|
|
terser({
|
|
compress: {
|
|
drop_console: true,
|
|
drop_debugger: true,
|
|
pure_funcs: ['console.log', 'console.warn'],
|
|
passes: 2,
|
|
},
|
|
format: { comments: false },
|
|
mangle: { toplevel: true },
|
|
}),
|
|
],
|
|
},
|
|
// TypeScript declarations bundle
|
|
{
|
|
input: 'src/index.ts',
|
|
output: {
|
|
file: 'dist/metona-editor.d.ts',
|
|
format: 'es',
|
|
},
|
|
plugins: [
|
|
dts(),
|
|
],
|
|
},
|
|
]),
|
|
];
|