@@ -11,6 +11,7 @@ import {
11
11
} from '@angular-devkit/build-optimizer' ;
12
12
import { tags } from '@angular-devkit/core' ;
13
13
import * as CopyWebpackPlugin from 'copy-webpack-plugin' ;
14
+ import { existsSync } from 'fs' ;
14
15
import * as path from 'path' ;
15
16
import { RollupOptions } from 'rollup' ;
16
17
import { ScriptTarget } from 'typescript' ;
@@ -214,23 +215,28 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
214
215
buildOptions . scripts ,
215
216
'scripts' ,
216
217
) . reduce ( ( prev : { bundleName : string ; paths : string [ ] ; inject : boolean } [ ] , curr ) => {
217
- const bundleName = curr . bundleName ;
218
- const resolvedPath = path . resolve ( root , curr . input ) ;
218
+ const { bundleName, inject, input } = curr ;
219
+ const resolvedPath = path . resolve ( root , input ) ;
220
+
221
+ if ( ! existsSync ( resolvedPath ) ) {
222
+ throw new Error ( `Script file ${ input } does not exist.` ) ;
223
+ }
224
+
219
225
const existingEntry = prev . find ( el => el . bundleName === bundleName ) ;
220
226
if ( existingEntry ) {
221
- if ( existingEntry . inject && ! curr . inject ) {
227
+ if ( existingEntry . inject && ! inject ) {
222
228
// All entries have to be lazy for the bundle to be lazy.
223
229
throw new Error (
224
- `The ${ curr . bundleName } bundle is mixing injected and non-injected scripts.` ,
230
+ `The ${ bundleName } bundle is mixing injected and non-injected scripts.` ,
225
231
) ;
226
232
}
227
233
228
234
existingEntry . paths . push ( resolvedPath ) ;
229
235
} else {
230
236
prev . push ( {
231
237
bundleName,
238
+ inject,
232
239
paths : [ resolvedPath ] ,
233
- inject : curr . inject ,
234
240
} ) ;
235
241
}
236
242
0 commit comments