Skip to content

Commit d5d7682

Browse files
authored
fix(webpack-cli): prefetch flag implementation (#1583)
1 parent c0c7f8c commit d5d7682

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const AdvancedGroup = require('../lib/groups/AdvancedGroup');
2+
3+
describe('AdvancedGroup', function () {
4+
it('should load the HMR Plugin', () => {
5+
const group = new AdvancedGroup([
6+
{
7+
hot: true,
8+
},
9+
]);
10+
11+
const result = group.run();
12+
expect(result.options.plugins[0].constructor.name).toEqual('HotModuleReplacementPlugin');
13+
});
14+
15+
it('should load the Prefetch Plugin', () => {
16+
const group = new AdvancedGroup([
17+
{
18+
prefetch: 'url',
19+
},
20+
]);
21+
22+
const result = group.run();
23+
expect(result.options.plugins[0].constructor.name).toEqual('PrefetchPlugin');
24+
});
25+
});

packages/webpack-cli/lib/groups/AdvancedGroup.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ class AdvancedGroup extends GroupHelper {
2525
if (options && options.plugins) {
2626
options.plugins.unshift(prefetchVal);
2727
} else {
28-
// Currently the Plugin function is not functional -> https://github.com/webpack/webpack-cli/pull/1140#discussion_r376761359
29-
// options.plugins = [prefetchVal];
28+
options.plugins = [prefetchVal];
3029
}
3130
}
3231
if (args.target) {

0 commit comments

Comments
 (0)