Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
Removed preloader from AoT Webpack config (#225)
Browse files Browse the repository at this point in the history
* Removed preloader from aot webpack config

* Update config-webpack-build-aot.spec.js
  • Loading branch information
Blackbaud-SteveBrush authored Jul 14, 2017
1 parent a66fb36 commit 06c7366
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
8 changes: 8 additions & 0 deletions config/webpack/build-aot.webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ function getWebpackConfig(skyPagesConfig) {
let commonConfig = common.getWebpackConfig(skyPagesConfig);
commonConfig.entry = null;

// Since the preloader is executed against the file system during an AoT build,
// we need to remove it from the webpack config, otherwise it will get executed twice.
commonConfig.module.rules = commonConfig.module.rules
.filter((rule) => {
const isPreloader = /\/sky-processor\//.test(rule.loader);
return (!isPreloader);
});

return webpackMerge(commonConfig, {
entry: {
polyfills: [skyPagesConfigUtil.spaPathTempSrc('polyfills.ts')],
Expand Down
38 changes: 37 additions & 1 deletion test/config-webpack-build-aot.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('config webpack build-aot', () => {
});

afterEach(() => {
mock.stop(ngtoolsWebpackPath);
mock.stopAll();
});

it('should expose a getWebpackConfig method', () => {
Expand Down Expand Up @@ -193,4 +193,40 @@ describe('config webpack build-aot', () => {
});
});

it('should remove the sky-processor loader from the rules array', () => {
const f = './common.webpack.config';
mock(f, {
getWebpackConfig: () => ({
module: {
rules: [
{
loader: '/sky-processor/'
}
]
}
})
});

const lib = require('../config/webpack/build-aot.webpack.config');

const skyPagesConfig = {
runtime: runtimeUtils.getDefaultRuntime(),
skyux: {}
};

const config = lib.getWebpackConfig(skyPagesConfig);

let found = false;

config.module.rules.forEach((rule) => {
if (found) {
return;
}

found = /\/sky-processor\//.test(rule.loader);
});

expect(found).toEqual(false);
});

});

0 comments on commit 06c7366

Please sign in to comment.