@@ -11,63 +11,69 @@ if you want to view the source, please visit the github repository of this plugi
1111*/
1212` ;
1313
14- const prod = process . argv [ 2 ] === " production" ;
14+ const prod = process . argv [ 2 ] === ' production' ;
1515
16- const context = await esbuild . context ( {
17- banner : {
18- js : banner
19- } ,
20- entryPoints : [ "src/main.ts" ] ,
21- bundle : true ,
22- external : [
23- "obsidian" ,
24- "electron" ,
25- "@codemirror/autocomplete" ,
26- "@codemirror/collab" ,
27- "@codemirror/commands" ,
28- "@codemirror/language" ,
29- "@codemirror/lint" ,
30- "@codemirror/search" ,
31- "@codemirror/state" ,
32- "@codemirror/view" ,
33- "@lezer/common" ,
34- "@lezer/highlight" ,
35- "@lezer/lr" ,
36- ...builtins
37- ] ,
38- format : "cjs" ,
39- target : "es2021" ,
40- logLevel : "info" ,
41- sourcemap : prod ? false : "inline" ,
42- treeShaking : true ,
43- outfile : "temp/vault/.obsidian/plugins/lineage-dev/main.js" ,
44- plugins : [
45- inlineWorkerPlugin ( { minify : prod } ) ,
46- esbuildSvelte ( {
47- compilerOptions : {
48- css : true
49- } ,
50- preprocess : sveltePreprocess ( ) ,
51- filterWarnings : ( warning ) => {
52- // disable a11y warnings
53- return ! ( warning . code . startsWith ( "a11y-" ) ) ;
54- }
16+ const options = {
17+ banner : {
18+ js : banner ,
19+ } ,
20+ entryPoints : [ 'src/main.ts' ] ,
21+ bundle : true ,
22+ external : [
23+ 'obsidian' ,
24+ 'electron' ,
25+ '@codemirror/autocomplete' ,
26+ '@codemirror/collab' ,
27+ '@codemirror/commands' ,
28+ '@codemirror/language' ,
29+ '@codemirror/lint' ,
30+ '@codemirror/search' ,
31+ '@codemirror/state' ,
32+ '@codemirror/view' ,
33+ '@lezer/common' ,
34+ '@lezer/highlight' ,
35+ '@lezer/lr' ,
36+ ...builtins ,
37+ ] ,
38+ format : 'cjs' ,
39+ target : 'es2021' ,
40+ logLevel : 'info' ,
41+ sourcemap : prod ? false : 'inline' ,
42+ treeShaking : true ,
43+ outfile : 'temp/vault/.obsidian/plugins/lineage-dev/main.js' ,
44+ plugins : [
45+ inlineWorkerPlugin ( { minify : prod } ) ,
46+ esbuildSvelte ( {
47+ compilerOptions : {
48+ css : true ,
49+ } ,
50+ preprocess : sveltePreprocess ( ) ,
51+ filterWarnings : ( warning ) => {
52+ // disable a11y warnings
53+ return ! warning . code . startsWith ( 'a11y-' ) ;
54+ } ,
55+ } ) ,
56+ ] ,
57+ } ;
58+ const context = await esbuild . context ( options ) ;
5559
56- } )
57-
58- ]
59- } ) ;
60-
61- const cssContext = await esbuild . context ( {
62- entryPoints : [ "src/styles/styles.css" , ] ,
63- bundle : true ,
64- outfile : "temp/vault/.obsidian/plugins/lineage-dev/styles.css"
65- } ) ;
60+ const cssOptions = {
61+ entryPoints : [ 'src/styles/styles.css' ] ,
62+ bundle : true ,
63+ outfile : 'temp/vault/.obsidian/plugins/lineage-dev/styles.css' ,
64+ } ;
65+ const cssContext = await esbuild . context ( cssOptions ) ;
6666
6767if ( prod ) {
68- await context . rebuild ( ) ;
69- await cssContext . rebuild ( ) ;
70- process . exit ( 0 ) ;
68+ await esbuild . build ( {
69+ ...options ,
70+ define : { 'process.env.NODE_ENV' : '"production"' } ,
71+ } ) ;
72+ await esbuild . build ( {
73+ ...cssOptions ,
74+ define : { 'process.env.NODE_ENV' : '"production"' } ,
75+ } ) ;
76+ process . exit ( 0 ) ;
7177} else {
72- await Promise . all ( [ cssContext . watch ( ) , context . watch ( ) ] ) ;
78+ await Promise . all ( [ cssContext . watch ( ) , context . watch ( ) ] ) ;
7379}
0 commit comments