1+ import fs from "node:fs" ;
2+ import path from "node:path" ;
13import typescript from "@rollup/plugin-typescript" ;
24import { nodeResolve } from "@rollup/plugin-node-resolve" ;
35import commonjs from "@rollup/plugin-commonjs" ;
46import json from "@rollup/plugin-json" ;
57import strip from '@rollup/plugin-strip' ;
68import terser from "@rollup/plugin-terser" ;
9+ import replace from "@rollup/plugin-replace" ;
10+ import manifest from "../manifest.json" assert { type : "json " } ;
11+
12+ function readMarkdown ( file ) {
13+ return fs . readFileSync ( path . resolve ( file ) , "utf8" ) ;
14+ }
715
816const isProd = ( process . env . BUILD === "production" ) ;
917
18+ const namePatternDE = readMarkdown ( "docs/namepattern.de.md" ) ;
19+ const namePatternEN = readMarkdown ( "docs/namepattern.en.md" ) ;
20+ const templateDE = readMarkdown ( "docs/template.de.md" ) ;
21+ const templateEN = readMarkdown ( "docs/template.en.md" ) ;
22+ const typeDE = readMarkdown ( "docs/type.de.md" ) ;
23+ const typeEN = readMarkdown ( "docs/type.en.md" ) ;
24+ const ribbonsDE = readMarkdown ( "docs/ribbons.de.md" ) ;
25+ const ribbonsEN = readMarkdown ( "docs/ribbons.en.md" ) ;
26+ const readme = readMarkdown ( "README.md" ) ;
27+
1028const banner =
1129`/*
1230 * THIS IS A GENERATED/BUNDLED FILE BY ROLLUP
@@ -33,15 +51,36 @@ export default {
3351 "@codemirror/autocomplete"
3452 ] ,
3553 plugins : [
36- json ( ) ,
54+ json ( ) , // required to import manifest.json
55+ replace ( {
56+ preventAssignment : true ,
57+ values : {
58+ __PLUGIN_FALLBACK_LANGUAGE__ : JSON . stringify ( "en" ) ,
59+ __PLUGIN_NAME__ : JSON . stringify ( manifest . name ) ,
60+ __PLUGIN_VERSION__ : JSON . stringify ( manifest . version ) ,
61+ __PLUGIN_AUTHOR__ : JSON . stringify ( manifest . author ) ,
62+ __PLUGIN_AUTHOR_URL__ : JSON . stringify ( manifest . authorUrl ) ,
63+ __PLUGIN_REPOSITORY__ : JSON . stringify ( manifest . repository ) ,
64+ __PLUGIN_DESCRIPTION__ : JSON . stringify ( manifest . description ) ,
65+ __PLUGIN_README_MD__ : JSON . stringify ( readme ) ,
66+ __PLUGIN_SETTINGS_NAMEPATTERN_CTXHLP_DE__ : JSON . stringify ( namePatternDE ) ,
67+ __PLUGIN_SETTINGS_NAMEPATTERN_CTXHLP_EN__ : JSON . stringify ( namePatternEN ) ,
68+ __PLUGIN_SETTINGS_TEMPLATE_CTXHLP_DE__ : JSON . stringify ( templateDE ) ,
69+ __PLUGIN_SETTINGS_TEMPLATE_CTXHLP_EN__ : JSON . stringify ( templateEN ) ,
70+ __PLUGIN_SETTINGS_TYPE_CTXHLP_DE__ : JSON . stringify ( typeDE ) ,
71+ __PLUGIN_SETTINGS_TYPE_CTXHLP_EN__ : JSON . stringify ( typeEN ) ,
72+ __PLUGIN_SETTINGS_RIBBONS_HELP_DE__ : JSON . stringify ( ribbonsDE ) ,
73+ __PLUGIN_SETTINGS_RIBBONS_HELP_EN__ : JSON . stringify ( ribbonsEN )
74+ } ,
75+ } ) ,
3776 typescript ( { tsconfig : ".config/tsconfig.build.json" } ) ,
3877 nodeResolve ( { browser : true } ) ,
3978 commonjs ( ) ,
4079 // Strip console and debugger statements first
4180 isProd && strip ( {
4281 include : '**/*.(js|ts)' ,
4382 exclude : 'src/lib/main.ts' , // console.logging: "Plugin loaded" should be available!
44- functions : [ 'console.*' ] ,
83+ functions : [ /* 'console.*'*/ ] ,
4584 debugger : true
4685 } ) ,
4786 // Remove all remaining comments
0 commit comments