Skip to content

Commit

Permalink
fix(webpack-cli): prefetch flag implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed May 27, 2020
1 parent c0c7f8c commit 215e258
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
25 changes: 25 additions & 0 deletions packages/webpack-cli/__tests__/AdvancedGroup.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const AdvancedGroup = require('../lib/groups/AdvancedGroup');

describe('AdvancedGroup', function () {
it('should load the HMR Plugin', () => {
const group = new AdvancedGroup([
{
hot: true,
},
]);

const result = group.run();
expect(result.options.plugins[0].constructor.name).toEqual('HotModuleReplacementPlugin');
});

it('should load the Prefetch Plugin', () => {
const group = new AdvancedGroup([
{
prefetch: 'url',
},
]);

const result = group.run();
expect(result.options.plugins[0].constructor.name).toEqual('PrefetchPlugin');
});
});
3 changes: 1 addition & 2 deletions packages/webpack-cli/lib/groups/AdvancedGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ class AdvancedGroup extends GroupHelper {
if (options && options.plugins) {
options.plugins.unshift(prefetchVal);
} else {
// Currently the Plugin function is not functional -> https://github.com/webpack/webpack-cli/pull/1140#discussion_r376761359
// options.plugins = [prefetchVal];
options.plugins = [prefetchVal];
}
}
if (args.target) {
Expand Down

0 comments on commit 215e258

Please sign in to comment.