Resource-hints-webpack-plugin: 自动化HTML资源提示注入

Resource-hints-webpack-plugin 是一个Webpack插件,用于自动将资源提示添加到HTML文件中,优化网页加载性能。

安装

确保您的Node.js版本在0.12.x或更高版本,然后使用npm或yarn安装插件:

# 使用npm安装
npm install --save-dev resource-hints-webpack-plugin

# 使用yarn安装
yarn add --dev resource-hints-webpack-plugin

使用方法

  1. 引入插件:
const ResourceHintWebpackPlugin = require('resource-hints-webpack-plugin');
  1. 在Webpack配置中添加插件:
plugins: [
  new HtmlWebpackPlugin(),
  new ResourceHintWebpackPlugin()
]
zip
resource-hints-webpack-plugin-master.zip 预估大小:12个文件
folder
resource-hints-webpack-plugin-master 文件夹
file
.node-version 6B
folder
spec 文件夹
folder
fixtures 文件夹
file
expected.html 263B
file
entry.js 28B
file
index.spec.js 4KB
folder
support 文件夹
file
jasmine.json 128B
file
.travis.yml 321B
file
LICENSE 1KB
file
README.md 2KB
file
.editorconfig 171B
file
.gitignore 36B
file
index.js 4KB
file
package.json 1KB
zip 文件大小:7.56KB