Files
MetonaEditor/rollup.config.js
T
thzxx 1cd5b63174
CI / test (16.x) (push) Canceled after 0s
CI / test (18.x) (push) Canceled after 0s
CI / test (20.x) (push) Canceled after 0s
feat: v0.2.1 — reference links, context menu, RTL, ja/ko, regex search, hooks, copy API
## Added
- Reference link/image resolution: [text][ref] + ![alt][ref] with [ref]: url definitions
- Right-click context menu: undo/redo/cut/copy/paste/selectAll + custom items
- RTL CSS layout support for Arabic, Hebrew, Persian etc.
- Japanese (ja) and Korean (ko) locales with 60+ keys each
- Divider position localStorage persistence
- Regex search toggle in search/replace panel
- Export HTML with embedded CSS styles
- beforeChange / afterChange lifecycle hooks (instance + global)
- copyAsMarkdown() / copyAsHTML() clipboard APIs
- CHANGELOG.md, CONTRIBUTING.md, CI workflow (.github/workflows/ci.yml)
- 2 new test suites: index.test.ts, styles.test.ts (684 total tests, +74)

## Changed
- autoSave plugin: closure-based state per instance instead of this context
- Plugin install() now receives options as second argument
- RTL locale detection: now uses language prefix (ar-SA → RTL)
- Rollup dev mode: only builds UMD format
- prepublishOnly now includes typecheck + test
- Version bumped to 0.2.1

## Fixed
- [text][ref] now correctly renders as link (was raw text)
- ![alt][ref] no longer produces empty src
- autoSave plugin state isolation across multiple editor instances
- Footnote definitions no longer consumed by refDef handler
2026-07-25 08:53:58 +08:00

119 lines
2.5 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 isProd = process.env.NODE_ENV === 'production';
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'],
}),
] : [];
const terserPlugin = isProd ? [
terser({
compress: {
drop_console: true,
drop_debugger: true,
pure_funcs: ['console.log', 'console.warn'],
},
format: {
comments: false,
},
}),
] : [];
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.esm.js',
format: 'es',
exports: 'named',
sourcemap: true,
},
plugins: basePlugins,
},
// CommonJS
{
input: 'src/index.ts',
output: {
file: 'dist/metona-editor.cjs.js',
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(),
],
},
]),
];