首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

restyle-loader

更新样式 <link>

带有散列值的 hreft值来触发样式重载

安装

代码语言:javascript
复制
npm install --save-dev restyle-loader

用法

例子

webpack.config.js

代码语言:javascript
复制
{
  test: /\.css?$/,
  use: [
    {
      loader: "restyle-loader"
    },
    {
      loader: "file-loader",
      options: {
        name: "[name].css?[hash:8]"
      }
    }
  ]
}

hash 需要启用热模块替换(Hot Module Replacement)

bundle.js

代码语言:javascript
复制
require("./index.css");

// Bundle code here...

index.html

代码语言:javascript
复制
<head>
  <link rel="stylesheet" type="text/css" href="css/index.css">
</head>

装载程序运行后,它变成

代码语言:javascript
复制
<head>
  <link rel="stylesheet" type="text/css" href="css/index.css?531fdfd0">
</head>

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com