@@ -22,22 +22,26 @@ const logger = buildLogger();
2222const templatePath = join ( __dirname , 'views/index.pug' ) ;
2323
2424export default class InfoApp implements App , Servable {
25-
2625 public static generatedFiles : string [ ] = [ ] ;
2726
28- public static build ( args : any , loadSupport : ( JsonConfig ) => Promise < SupportConfig > ) : Promise < App > {
29-
27+ public static build (
28+ args : any ,
29+ loadSupport : ( JsonConfig ) => Promise < SupportConfig >
30+ ) : Promise < App > {
3031 const dir = resolve ( args . dir || process . cwd ( ) ) ;
3132
3233 if ( ! existsSync ( join ( dir , 'docs/demo' ) ) ) {
33- throw new Error ( `Can't find a 'docs/demo' directory in path: ${ dir } . Is this a pie directory?` ) ;
34+ throw new Error (
35+ `Can't find a 'docs/demo' directory in path: ${ dir } . Is this a pie directory?`
36+ ) ;
3437 }
3538
3639 const config = JsonConfig . build ( join ( dir , 'docs/demo' ) , args ) ;
3740 const session = Session . build ( join ( dir , 'docs/demo' ) , args ) ;
3841
39- return loadSupport ( config )
40- . then ( support => new InfoApp ( dir , config , support , session ) ) ;
42+ return loadSupport ( config ) . then (
43+ support => new InfoApp ( dir , config , support , session )
44+ ) ;
4145 }
4246
4347 private static BUNDLE = 'info.bundle.js' ;
@@ -46,11 +50,12 @@ export default class InfoApp implements App, Servable {
4650 private template : any ;
4751 private installer : Install ;
4852
49- constructor ( private pieRoot : string ,
53+ constructor (
54+ private pieRoot : string ,
5055 readonly config : JsonConfig ,
5156 private support : SupportConfig ,
52- readonly session : Session ) {
53-
57+ readonly session : Session
58+ ) {
5459 this . template = pug . compileFile ( templatePath ) ;
5560
5661 this . installer = new Install ( config . dir , config . raw ) ;
@@ -62,7 +67,7 @@ export default class InfoApp implements App, Servable {
6267 public watchableFiles ( ) : string [ ] {
6368 return [
6469 resolve ( join ( this . pieRoot , 'README.md' ) ) ,
65- resolve ( join ( this . pieRoot , 'package.json' ) ) ,
70+ resolve ( join ( this . pieRoot , 'package.json' ) )
6671 ] ;
6772 }
6873
@@ -74,35 +79,42 @@ export default class InfoApp implements App, Servable {
7479
7580 await writeEntryJs ( join ( dirs . root , InfoApp . ENTRY ) , js ) ;
7681
77- const config = webpackConfig ( dirs , this . support , InfoApp . ENTRY , InfoApp . BUNDLE , null , opts . sourceMaps ) ;
82+ const resolveModules = [ dirs . root , dirs . configure , dirs . controllers ] ;
83+ const config = webpackConfig (
84+ resolveModules ,
85+ dirs . root ,
86+ this . support ,
87+ InfoApp . ENTRY ,
88+ InfoApp . BUNDLE ,
89+ null ,
90+ opts . sourceMaps
91+ ) ;
7892
7993 const cssRule = config . module . rules . find ( u => {
8094 const match = u . test . source === '\\.css$' ;
8195 return match ;
8296 } ) ;
8397
84- cssRule . exclude = [
85- / .* h i g h l i g h t \. j s .* / ,
86- ] ;
98+ cssRule . exclude = [ / .* h i g h l i g h t \. j s .* / ] ;
8799
88100 // load in raw css for markdown element
89- config . module . rules = [ {
90- test : / . * h i g h l i g h t \. j s . * d e f a u l t \. c s s $ / ,
91- use : [
92- 'raw-loader' ,
93- ] ,
94- } ,
95- {
96- test : / \. ( p n g | j p g | g i f | s v g | e o t | t t f | w o f f | w o f f 2 | o t f ) $ / ,
97- use : [
98- {
99- loader : 'url-loader' ,
100- options : {
101- limit : 10000
101+ config . module . rules = [
102+ {
103+ test : / . * h i g h l i g h t \. j s . * d e f a u l t \. c s s $ / ,
104+ use : [ 'raw-loader' ]
105+ } ,
106+ {
107+ test : / \. ( p n g | j p g | g i f | s v g | e o t | t t f | w o f f | w o f f 2 | o t f ) $ / ,
108+ use : [
109+ {
110+ loader : 'url-loader' ,
111+ options : {
112+ limit : 10000
113+ }
102114 }
103- }
104- ]
105- } ] . concat ( config . module . rules ) ;
115+ ]
116+ }
117+ ] . concat ( config . module . rules ) ;
106118
107119 writeConfig ( join ( dirs . root , 'info.webpack.config.js' ) , config ) ;
108120
@@ -115,7 +127,7 @@ export default class InfoApp implements App, Servable {
115127
116128 linkCompilerToServer ( 'main' , compiler , server ) ;
117129
118- const reload = ( name ) => {
130+ const reload = name => {
119131 logger . info ( 'File Changed: ' , name ) ;
120132 this . config . reload ( ) ;
121133 this . session . reload ( ) ;
@@ -126,12 +138,11 @@ export default class InfoApp implements App, Servable {
126138 dirs,
127139 pkgs,
128140 reload,
129- server : server . httpServer ,
141+ server : server . httpServer
130142 } ;
131143 }
132144
133145 private router ( compiler : webpack . Compiler ) : express . Router {
134-
135146 const router = express . Router ( ) ;
136147
137148 const middleware = webpackMiddleware ( compiler , {
@@ -147,12 +158,10 @@ export default class InfoApp implements App, Servable {
147158 router . use ( middleware ) ;
148159
149160 router . get ( '/' , ( req , res ) => {
150-
151161 const pkg = readJsonSync ( join ( this . pieRoot , 'package.json' ) ) ;
152162 const readme = readFileSync ( join ( this . pieRoot , 'README.md' ) , 'utf8' ) ;
153163
154164 const page = this . template ( {
155-
156165 demo : {
157166 config : {
158167 langs : this . config . langs ,
@@ -174,7 +183,7 @@ export default class InfoApp implements App, Servable {
174183 `/${ InfoApp . BUNDLE } `
175184 ] ) ,
176185 orgRepo : {
177- repo : pkg . name ,
186+ repo : pkg . name
178187 }
179188 } ) ;
180189
0 commit comments