fix(@angular/cli): include polyfills before scripts in ng test

Fix #4545
Close #4656
This commit is contained in:
Filipe Silva 2017-02-13 11:57:24 +00:00
parent 7ea80135a3
commit ca29eabd19

View File

@ -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'];