@@ -39,7 +39,7 @@ module.exports = function build (args, options) {
3939}
4040
4141function buildCore ( conf , options ) {
42- const buildSpinner = ora ( ` Starting build, please wait🤡~` ) . start ( )
42+ const buildSpinner = ora ( ' Starting build, please wait🤡~' ) . start ( )
4343 const appConf = conf . appConf
4444 const buildConfig = getAppBuildConfig ( conf . appPath )
4545 const {
@@ -66,21 +66,6 @@ function buildCore (conf, options) {
6666 } else {
6767 customWebpackConf = buildConfig . webpack
6868 }
69- let dllWebpackCompiler
70- let libContext
71- const library = buildConfig . library
72- let vendorFiles = [ ]
73- let libraryDir
74- if ( conf . buildType === BUILD_APP ) {
75- if ( library && ! isEmptyObject ( library ) ) {
76- libraryDir = library . directory || 'lib'
77- libContext = path . join ( conf . appPath , outputRoot , libraryDir )
78- fs . ensureDirSync ( libContext )
79- const webpackDllConf = require ( '../config/dll.conf' ) ( libContext , buildConfig , library )
80- dllWebpackCompiler = webpack ( webpackDllConf )
81- }
82- }
83- buildConfig . library = library
8469 const webpackBaseConf = require ( '../config/base.conf' ) ( conf . appPath , buildConfig , template , platform , framework )
8570 const webpackProdConf = require ( '../config/prod.conf' ) ( conf . appPath , buildConfig , template , platform , framework )
8671 let webpackConf = webpackMerge ( webpackBaseConf , webpackProdConf )
@@ -103,125 +88,36 @@ function buildCore (conf, options) {
10388 }
10489 } ) )
10590 }
106- if ( dllWebpackCompiler ) {
107- dllWebpackCompiler . run ( ( err , stats ) => {
108- if ( err ) {
109- return printBuildError ( err )
110- }
111- const { errors, warnings } = formatWebpackMessage ( stats . toJson ( { } , true ) )
112- const isSuccess = ! errors . length && ! warnings . length
113- if ( isSuccess ) {
114- webpackConf . plugins . push (
115- new webpack . DllReferencePlugin ( {
116- context : libContext ,
117- manifest : require ( path . join ( libContext , `${ library . name || 'vendor' } -manifest.json` ) )
118- } )
119- )
120- if ( libContext ) {
121- vendorFiles = fs . readdirSync ( libContext ) . map ( file => {
122- if ( / d l l \. j s $ / . test ( file ) ) {
123- return `${ publicPath } ${ urlJoin ( libraryDir , file ) } `
124- }
125- return null
126- } ) . filter ( Boolean )
127- }
128- if ( appConf . template === 'complete' ) {
129- for ( const mod in htmlPages ) {
130- for ( const page in htmlPages [ mod ] ) {
131- const pageItem = htmlPages [ mod ] [ page ]
132- webpackConf . plugins . push ( new HtmlWebpackPlugin ( {
133- filename : `${ mod } /${ pageItem . filename } ` ,
134- template : pageItem . filepath ,
135- alwaysWriteToDisk : true ,
136- chunks : [ `${ mod } /${ page } ` ] ,
137- vendorFiles
138- } ) )
139- }
140- }
141- } else {
142- webpackConf . plugins . push ( new HtmlWebpackPlugin ( {
143- filename : 'index.html' ,
144- template : htmlPages [ 'index' ] ,
145- alwaysWriteToDisk : true ,
146- chunks : 'index.js' ,
147- vendorFiles
148- } ) )
149- }
150- webpackConf = webpackMerge ( webpackConf , customWebpackConf )
151- const compiler = createCompiler ( webpack , webpackConf )
152- return buildCompilerRun ( compiler , buildSpinner , conf , options )
153- }
154- if ( errors . length ) {
155- errors . splice ( 1 )
156- buildSpinner . fail ( chalk . red ( 'Compile library failed!\n' ) )
157- return printBuildError ( new Error ( errors . join ( '\n\n' ) ) )
158- }
159- if ( warnings . length ) {
160- buildSpinner . warn ( chalk . yellow ( 'Library Compiled with warnings.\n' ) )
161- console . log ( warnings . join ( '\n\n' ) )
162- console . log (
163- '\nSearch for the ' +
164- chalk . underline ( chalk . yellow ( 'keywords' ) ) +
165- ' to learn more about each warning.'
166- )
167- console . log (
168- 'To ignore, add ' +
169- chalk . cyan ( '// eslint-disable-next-line' ) +
170- ' to the line before.\n'
171- )
172- }
173- } )
174- } else {
175- if ( library && ! isEmptyObject ( library ) ) {
176- webpackConf . plugins . push (
177- new webpack . DllReferencePlugin ( {
178- context : libContext ,
179- manifest : require ( path . join ( libContext , `${ library . name || 'vendor' } -manifest.json` ) )
180- } )
181- )
182- }
183- if ( libContext ) {
184- vendorFiles = fs . readdirSync ( libContext ) . map ( file => {
185- if ( / d l l \. j s $ / . test ( file ) ) {
186- return `${ publicPath } ${ urlJoin ( libraryDir , file ) } `
187- }
188- return null
189- } ) . filter ( Boolean )
190- }
191- if ( appConf . template === 'complete' ) {
192- for ( const mod in htmlPages ) {
193- for ( const page in htmlPages [ mod ] ) {
194- const pageItem = htmlPages [ mod ] [ page ]
195- webpackConf . plugins . push ( new HtmlWebpackPlugin ( {
196- filename : `${ mod } /${ pageItem . filename } ` ,
197- template : pageItem . filepath ,
198- alwaysWriteToDisk : true ,
199- chunks : [ `${ mod } /${ page } ` ] ,
200- vendorFiles
201- } ) )
202- }
91+ if ( appConf . template === 'complete' ) {
92+ for ( const mod in htmlPages ) {
93+ for ( const page in htmlPages [ mod ] ) {
94+ const pageItem = htmlPages [ mod ] [ page ]
95+ webpackConf . plugins . push ( new HtmlWebpackPlugin ( {
96+ filename : `${ mod } /${ pageItem . filename } ` ,
97+ template : pageItem . filepath ,
98+ alwaysWriteToDisk : true ,
99+ chunks : [ `${ mod } /${ page } ` ]
100+ } ) )
203101 }
204- } else {
205- webpackConf . plugins . push ( new HtmlWebpackPlugin ( {
206- filename : 'index.html' ,
207- template : htmlPages [ 'index' ] ,
208- alwaysWriteToDisk : true ,
209- chunks : 'index.js' ,
210- vendorFiles
211- } ) )
212102 }
213- webpackConf = webpackMerge ( webpackConf , customWebpackConf )
214- const compiler = createCompiler ( webpack , webpackConf )
215- buildCompilerRun ( compiler , buildSpinner , conf , options )
103+ } else {
104+ webpackConf . plugins . push ( new HtmlWebpackPlugin ( {
105+ filename : 'index.html' ,
106+ template : htmlPages . index ,
107+ alwaysWriteToDisk : true ,
108+ chunks : 'index.js'
109+ } ) )
216110 }
111+ webpackConf = webpackMerge ( webpackConf , customWebpackConf )
112+ const compiler = createCompiler ( webpack , webpackConf )
113+ buildCompilerRun ( compiler , buildSpinner , conf , options )
217114}
218115
219116function buildCompilerRun ( compiler , buildSpinner , conf , options ) {
220117 compiler . run ( ( err , stats ) => {
221118 if ( err ) {
222119 return printBuildError ( err )
223120 }
224-
225121 const { errors, warnings } = formatWebpackMessage ( stats . toJson ( { } , true ) )
226122 const isSuccess = ! errors . length && ! warnings . length
227123 if ( isSuccess ) {
0 commit comments