-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(prefetch + preload): 增加prefetch跟preload
- Loading branch information
luoxue
committed
Dec 16, 2019
1 parent
08666da
commit 80903d3
Showing
8 changed files
with
34 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// [PreloadWebpackPlugin] | ||
// npm install preload-webpack-plugin@next | ||
module.exports = ({ config, resolve, options }) => { | ||
const PreloadWebpackPlugin = require('preload-webpack-plugin') | ||
return () => { | ||
config.plugin('preload') | ||
.use(PreloadWebpackPlugin, [{ | ||
rel: 'preload', | ||
as(entry) { | ||
if (/\.css$/.test(entry)) return 'style' | ||
if (/\.woff$/.test(entry)) return 'font' | ||
if (/\.png$/.test(entry)) return 'image' | ||
return 'script' | ||
} | ||
}]) | ||
config | ||
.plugin('prefetch') | ||
.use(PreloadWebpackPlugin, [{ | ||
rel: 'prefetch', | ||
include: 'asyncChunks' | ||
}]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters