11/*
2- * @package : gistr
3- * @module : obsidian.md
4- * @author : Aetherinox
5- * @url : https://github.com/Aetherinox/obsidian-gistr
6- */
2+ * @package : gistr
3+ * @module : obsidian.md
4+ * @author : Aetherinox
5+ * @url : https://github.com/Aetherinox/obsidian-gistr
6+ */
77
88/*
9- * import
10- */
9+ * import
10+ */
1111
1212import typescript from '@rollup/plugin-typescript' ;
1313import { nodeResolve } from '@rollup/plugin-node-resolve' ;
@@ -21,55 +21,56 @@ import { v5 as uuidv5 } from 'uuid';
2121import { readFileSync , writeFileSync } from 'fs' ;
2222
2323/*
24- * declrations > package.json
25- */
24+ * declrations > package.json
25+ */
2626
27- const {
27+ const
28+ {
2829 name,
2930 author,
3031 version,
3132 repository
32- } = JSON . parse ( readFileSync ( './package.json' ) ) ;
33+ } = JSON . parse ( readFileSync ( './package.json' ) ) ;
3334
3435/*
35- * declrations > constants
36- */
37-
38- const now = moment ( ) . milliseconds ( 0 ) . toISOString ( ) ;
39- const build_date = now ;
40- const bIsProd = ( process . env . BUILD === 'production' ) ;
41- const bIsDev = ( process . env . BUILD === 'dev' ) ;
42- const year = moment ( now ) . year ( ) ;
43- const build_guid = uuidv5 ( ` + repository + ` , uuidv5 . URL )
44- const build_uuid = uuidv5 ( version , build_guid )
45- const path_save_home = './'
46- const path_save_dist = 'dist/'
36+ * declrations > constants
37+ */
38+
39+ const now = moment ( ) . milliseconds ( 0 ) . toISOString ( ) ;
40+ const build_date = now ;
41+ const bIsProd = ( process . env . BUILD === 'production' ) ;
42+ const bIsDev = ( process . env . BUILD === 'dev' ) ;
43+ const year = moment ( now ) . year ( ) ;
44+ const build_guid = uuidv5 ( ` + repository + ` , uuidv5 . URL )
45+ const build_uuid = uuidv5 ( version , build_guid )
46+ const path_save_home = './'
47+ const path_save_dist = 'dist/'
4748
4849/*
49- * write build id to file
50- *
51- * export $(cat .env | xargs)
52- */
50+ * write build id to file
51+ *
52+ * export $(cat .env | xargs)
53+ */
5354
5455const ids = `
5556GUID=${ build_guid }
5657UUID=${ build_uuid }
5758` ;
5859
5960/*
60- * write const ids to .env file
61- */
61+ * write const ids to .env file
62+ */
6263
63- writeFileSync ( ".env" , ids ,
64+ writeFileSync ( ".env" , ids ,
6465{
6566 flag : "w"
6667} )
6768
6869const asdad = process . env . NAME = "reee"
6970
7071/*
71- * banner
72- */
72+ * banner
73+ */
7374
7475const header_banner = `
7576@name: ${ name } v${ version }
@@ -83,64 +84,81 @@ const header_banner = `
8384` ;
8485
8586/*
86- * banner output
87- */
87+ * banner output
88+ */
8889
89- console . log ( header_banner ) ;
90- console . log ( `Running in ${ bIsDev ? 'development' : 'production' } mode` ) ;
90+ console . log ( header_banner ) ;
91+ console . log ( `Running in ${ bIsDev ? 'development' : 'production' } mode` ) ;
9192
9293/*
93- * rollup config
94- */
95-
96- export default {
97- input : 'src/main.ts' ,
98- output : {
99- dir : path_save_home ,
100- sourcemap : 'inline' ,
101- sourcemapExcludeSources : bIsProd ,
102- format : 'cjs' ,
103- exports : 'named'
104- } ,
105- external : [
106- 'obsidian' ,
107- 'electron' ,
108- 'uuid' ,
109- ] ,
110- plugins : [
111- replace ( {
112- preventAssignment : true ,
113- values : {
114- "process.env.NODE_ENV" : bIsProd ? '"production"' : '"dev"' ,
115- "process.env.ENV" : bIsProd ? '"production"' : '"dev"' ,
116- "process.env.BUILD" : bIsProd ? '"production"' : '"dev"' ,
117- "process.env.PLUGIN_VERSION" : `"${ version } "` ,
118- "process.env.BUILD_GUID" : `"${ build_guid } "` ,
119- "process.env.BUILD_UUID" : `"${ build_uuid } "` ,
120- "process.env.BUILD_DATE" : JSON . stringify ( moment ( now ) ) ,
121- "process.env.AUTHOR" : `"${ author } "` ,
122- } ,
123- } ) ,
124- typescript ( ) ,
125- nodeResolve ( { browser : true } ) ,
126- commonjs ( ) ,
127- image ( ) ,
128- terser ( {
129- ecma : 2020 ,
130- mangle : { toplevel : true } ,
131- compress : {
132- module : true ,
133- toplevel : true ,
134- unsafe_arrows : true
135- } ,
136- format : { comments : false }
137- } ) ,
138- license ( {
139- sourcemap : true ,
140- banner : {
141- content : `${ header_banner } ` ,
142- commentStyle : 'regular' ,
143- } ,
144- } ) ,
145- ]
146- } ;
94+ * rollup config
95+ */
96+
97+ export default
98+ {
99+ input : 'src/main.ts' ,
100+ output :
101+ {
102+ dir : path_save_home ,
103+ sourcemap : 'inline' ,
104+ sourcemapExcludeSources : bIsProd ,
105+ format : 'cjs' ,
106+ exports : 'named'
107+ } ,
108+ external : [
109+ 'obsidian' ,
110+ 'electron' ,
111+ 'uuid' ,
112+ ] ,
113+ plugins : [
114+ replace (
115+ {
116+ preventAssignment : true ,
117+ values :
118+ {
119+ "process.env.NODE_ENV" : bIsProd ? '"production"' : '"dev"' ,
120+ "process.env.ENV" : bIsProd ? '"production"' : '"dev"' ,
121+ "process.env.BUILD" : bIsProd ? '"production"' : '"dev"' ,
122+ "process.env.PLUGIN_VERSION" : `"${ version } "` ,
123+ "process.env.BUILD_GUID" : `"${ build_guid } "` ,
124+ "process.env.BUILD_UUID" : `"${ build_uuid } "` ,
125+ "process.env.BUILD_DATE" : JSON . stringify ( moment ( now ) ) ,
126+ "process.env.AUTHOR" : `"${ author } "` ,
127+ } ,
128+ } ) ,
129+ typescript ( ) ,
130+ nodeResolve (
131+ {
132+ browser : true
133+ } ) ,
134+ commonjs ( ) ,
135+ image ( ) ,
136+ terser (
137+ {
138+ ecma : 2020 ,
139+ mangle :
140+ {
141+ toplevel : true
142+ } ,
143+ compress :
144+ {
145+ module : true ,
146+ toplevel : true ,
147+ unsafe_arrows : true
148+ } ,
149+ format :
150+ {
151+ comments : false
152+ }
153+ } ) ,
154+ license (
155+ {
156+ sourcemap : true ,
157+ banner :
158+ {
159+ content : `${ header_banner } ` ,
160+ commentStyle : 'regular' ,
161+ } ,
162+ } ) ,
163+ ]
164+ } ;
0 commit comments