Skip to content

Commit

Permalink
fix(@angular/cli): include polyfills before scripts in ng test
Browse files Browse the repository at this point in the history
Fix #4545
Close #4656
  • Loading branch information
filipesilva committed Feb 15, 2017
1 parent 7ea8013 commit ca29eab
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions packages/@angular/cli/plugins/karma.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'];
Expand Down

0 comments on commit ca29eab

Please sign in to comment.