@@ -32,83 +32,89 @@ async function build(opts) {
3232 nodeResolve ( ) ,
3333 replace ( {
3434 __VERSION__ : version ,
35- } )
35+ } ) ,
3636 ] ,
3737 onwarn ( message ) {
3838 if ( message . code === 'UNRESOLVED_IMPORT' ) {
3939 throw new Error (
4040 `Could not resolve module ` +
41- message . source +
42- `. Try running 'npm install' or using rollup's 'external' option if this is an external dependency. ` +
43- `Module ${ message . source } is imported in ${ message . importer } `
44- )
41+ message . source +
42+ `. Try running 'npm install' or using rollup's 'external' option if this is an external dependency. ` +
43+ `Module ${ message . source } is imported in ${ message . importer } `
44+ ) ;
4545 }
46- }
46+ } ,
4747 } )
4848 . then ( bundle => {
49- const dest = 'lib/' + ( opts . output || opts . input )
49+ const dest = 'lib/' + ( opts . output || opts . input ) ;
5050
51- console . log ( dest )
51+ console . log ( dest ) ;
5252 return bundle . write ( {
5353 format : 'iife' ,
54- output : opts . globalName ? { name : opts . globalName } : { } ,
54+ output : opts . globalName ? { name : opts . globalName } : { } ,
5555 file : dest ,
56- strict : false
57- } )
58- } )
56+ strict : false ,
57+ } ) ;
58+ } ) ;
5959}
6060
6161async function buildCore ( ) {
62- const promises = [ ]
62+ const promises = [ ] ;
6363
64- promises . push ( build ( {
65- input : 'src/core/index.js' ,
66- output : 'docsify.js' ,
67- } ) )
64+ promises . push (
65+ build ( {
66+ input : 'src/core/index.js' ,
67+ output : 'docsify.js' ,
68+ } )
69+ ) ;
6870
6971 if ( isProd ) {
70- promises . push ( build ( {
71- input : 'src/core/index.js' ,
72- output : 'docsify.min.js' ,
73- plugins : [ uglify ( ) ]
74- } ) )
72+ promises . push (
73+ build ( {
74+ input : 'src/core/index.js' ,
75+ output : 'docsify.min.js' ,
76+ plugins : [ uglify ( ) ] ,
77+ } )
78+ ) ;
7579 }
7680
77- await Promise . all ( promises )
81+ await Promise . all ( promises ) ;
7882}
7983
8084async function buildAllPlugin ( ) {
8185 const plugins = [
82- { name : 'search' , input : 'search/index.js' } ,
83- { name : 'ga' , input : 'ga.js' } ,
84- { name : 'gtag' , input : 'gtag.js' } ,
85- { name : 'matomo' , input : 'matomo.js' } ,
86- { name : 'emoji' , input : 'emoji.js' } ,
87- { name : 'external-script' , input : 'external-script.js' } ,
88- { name : 'front-matter' , input : 'front-matter/index.js' } ,
89- { name : 'zoom-image' , input : 'zoom-image.js' } ,
90- { name : 'disqus' , input : 'disqus.js' } ,
91- { name : 'gitalk' , input : 'gitalk.js' }
92- ]
86+ { name : 'search' , input : 'search/index.js' } ,
87+ { name : 'ga' , input : 'ga.js' } ,
88+ { name : 'gtag' , input : 'gtag.js' } ,
89+ { name : 'matomo' , input : 'matomo.js' } ,
90+ { name : 'emoji' , input : 'emoji.js' } ,
91+ { name : 'external-script' , input : 'external-script.js' } ,
92+ { name : 'front-matter' , input : 'front-matter/index.js' } ,
93+ { name : 'zoom-image' , input : 'zoom-image.js' } ,
94+ { name : 'disqus' , input : 'disqus.js' } ,
95+ { name : 'gitalk' , input : 'gitalk.js' } ,
96+ ] ;
9397
9498 const promises = plugins . map ( item => {
9599 return build ( {
96100 input : 'src/plugins/' + item . input ,
97- output : 'plugins/' + item . name + '.js'
98- } )
99- } )
101+ output : 'plugins/' + item . name + '.js' ,
102+ } ) ;
103+ } ) ;
100104
101105 if ( isProd ) {
102106 plugins . forEach ( item => {
103- promises . push ( build ( {
104- input : 'src/plugins/' + item . input ,
105- output : 'plugins/' + item . name + '.min.js' ,
106- plugins : [ uglify ( ) ]
107- } ) )
108- } )
107+ promises . push (
108+ build ( {
109+ input : 'src/plugins/' + item . input ,
110+ output : 'plugins/' + item . name + '.min.js' ,
111+ plugins : [ uglify ( ) ] ,
112+ } )
113+ ) ;
114+ } ) ;
109115 }
110116
111- await Promise . all ( promises )
117+ await Promise . all ( promises ) ;
112118}
113119
114120async function main ( ) {
@@ -118,41 +124,37 @@ async function main() {
118124 atomic : true ,
119125 awaitWriteFinish : {
120126 stabilityThreshold : 1000 ,
121- pollInterval : 100
122- }
127+ pollInterval : 100 ,
128+ } ,
123129 } )
124130 . on ( 'change' , p => {
125- console . log ( '[watch] ' , p )
126- const dirs = p . split ( path . sep )
131+ console . log ( '[watch] ' , p ) ;
132+ const dirs = p . split ( path . sep ) ;
127133 if ( dirs [ 1 ] === 'core' ) {
128- buildCore ( )
134+ buildCore ( ) ;
129135 } else if ( dirs [ 2 ] ) {
130- const name = path . basename ( dirs [ 2 ] , '.js' )
136+ const name = path . basename ( dirs [ 2 ] , '.js' ) ;
131137 const input = `src/plugins/${ name } ${
132138 / \. j s / . test ( dirs [ 2 ] ) ? '' : '/index'
133- } .js`
139+ } .js`;
134140
135141 build ( {
136142 input,
137- output : 'plugins/' + name + '.js'
138- } )
143+ output : 'plugins/' + name + '.js' ,
144+ } ) ;
139145 }
140146 } )
141147 . on ( 'ready' , ( ) => {
142- console . log ( '[start]' )
143- buildCore ( )
144- buildAllPlugin ( )
145- } )
148+ console . log ( '[start]' ) ;
149+ buildCore ( ) ;
150+ buildAllPlugin ( ) ;
151+ } ) ;
146152 } else {
147- await Promise . all ( [
148- buildCore ( ) ,
149- buildAllPlugin ( )
150- ] )
153+ await Promise . all ( [ buildCore ( ) , buildAllPlugin ( ) ] ) ;
151154 }
152155}
153156
154- main ( ) . catch ( ( e ) => {
155- console . error ( e )
156- process . exit ( 1 )
157- } )
158-
157+ main ( ) . catch ( e => {
158+ console . error ( e ) ;
159+ process . exit ( 1 ) ;
160+ } ) ;
0 commit comments