mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-21 22:34:21 +08:00
fix(@angular/cli): include polyfills before scripts in ng test
Fix #4545 Close #4656
This commit is contained in:
parent
7ea80135a3
commit
ca29eabd19
@ -67,19 +67,6 @@ const init = (config) => {
|
||||
.map((file) => config.preprocessors[file])
|
||||
.map((arr) => arr.splice(arr.indexOf('@angular/cli'), 1, 'webpack', 'sourcemap'));
|
||||
|
||||
// Add polyfills file
|
||||
if (appConfig.polyfills) {
|
||||
const polyfillsFile = path.resolve(appRoot, appConfig.polyfills);
|
||||
const polyfillsPattern = {
|
||||
pattern: polyfillsFile,
|
||||
included: true,
|
||||
served: true,
|
||||
watched: true
|
||||
}
|
||||
Array.prototype.unshift.apply(config.files, [polyfillsPattern]);
|
||||
config.preprocessors[polyfillsFile] = ['webpack', 'sourcemap'];
|
||||
}
|
||||
|
||||
// Add global scripts
|
||||
if (appConfig.scripts && appConfig.scripts.length > 0) {
|
||||
const globalScriptPatterns = appConfig.scripts
|
||||
@ -98,6 +85,19 @@ const init = (config) => {
|
||||
// karma already has a reference to the existing array.
|
||||
Array.prototype.unshift.apply(config.files, globalScriptPatterns);
|
||||
}
|
||||
|
||||
// Add polyfills file before everything else
|
||||
if (appConfig.polyfills) {
|
||||
const polyfillsFile = path.resolve(appRoot, appConfig.polyfills);
|
||||
const polyfillsPattern = {
|
||||
pattern: polyfillsFile,
|
||||
included: true,
|
||||
served: true,
|
||||
watched: true
|
||||
}
|
||||
Array.prototype.unshift.apply(config.files, [polyfillsPattern]);
|
||||
config.preprocessors[polyfillsFile] = ['webpack', 'sourcemap'];
|
||||
}
|
||||
}
|
||||
|
||||
init.$inject = ['config'];
|
||||
|
Loading…
x
Reference in New Issue
Block a user