Skip to content
This repository was archived by the owner on Jan 21, 2021. It is now read-only.

Commit 951ff9c

Browse files
authored
Merge pull request #51 from vuejs/master
support include: 'initial'
2 parents d1abc3c + 3bbf7b1 commit 951ff9c

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,14 @@ will be injected into the document `<head>`:
132132
<link rel="preload" as="script" href="chunk.d15e7fdfc91b34bb78c4.js">
133133
```
134134

135-
You can also configure the plugin to preload all chunks (vendor, async, normal chunks) using
136-
`include`:
135+
You can also configure the plugin to preload all chunks (vendor, async, normal chunks) using `include: 'all'`, or only preload initial chunks with `include: 'initial'`:
137136

138137
```js
139138
plugins: [
140139
new HtmlWebpackPlugin(),
141140
new PreloadWebpackPlugin({
142141
rel: 'preload',
143-
include: 'all'
142+
include: 'all' // or 'initial'
144143
})
145144
]
146145
```

index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ class PreloadPlugin {
7373
} catch (e) {
7474
extractedChunks = compilation.chunks;
7575
}
76+
} else if (options.include === 'initial') {
77+
try {
78+
extractedChunks = compilation.chunks.filter(chunk => chunk.isInitial());
79+
} catch (e) {
80+
extractedChunks = compilation.chunks;
81+
}
7682
} else if (options.include === 'all') {
7783
// Async chunks, vendor chunks, normal chunks.
7884
extractedChunks = compilation.chunks;

0 commit comments

Comments
 (0)