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

Commit

Permalink
Merge pull request #51 from vuejs/master
Browse files Browse the repository at this point in the history
support include: 'initial'
  • Loading branch information
jeffposnick authored Jan 11, 2018
2 parents d1abc3c + 3bbf7b1 commit 951ff9c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,14 @@ will be injected into the document `<head>`:
<link rel="preload" as="script" href="chunk.d15e7fdfc91b34bb78c4.js">
```

You can also configure the plugin to preload all chunks (vendor, async, normal chunks) using
`include`:
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'`:

```js
plugins: [
new HtmlWebpackPlugin(),
new PreloadWebpackPlugin({
rel: 'preload',
include: 'all'
include: 'all' // or 'initial'
})
]
```
Expand Down
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ class PreloadPlugin {
} catch (e) {
extractedChunks = compilation.chunks;
}
} else if (options.include === 'initial') {
try {
extractedChunks = compilation.chunks.filter(chunk => chunk.isInitial());
} catch (e) {
extractedChunks = compilation.chunks;
}
} else if (options.include === 'all') {
// Async chunks, vendor chunks, normal chunks.
extractedChunks = compilation.chunks;
Expand Down

0 comments on commit 951ff9c

Please sign in to comment.