restyle-loader

restyle-loader

Updates style <link>

href value with a hash to trigger a style reload

Install

npm install --save-dev restyle-loader

Usage

Documentation: Using loaders

Examples

webpack.config.js

{
  test: /\.css?$/,
  use: [
    {
      loader: "restyle-loader"
    },
    {
      loader: "file-loader",
      options: {
        name: "[name].css?[hash:8]"
      }
    }
  ]
}

Hash is required to enable HMR

bundle.js

require("./index.css");

// Bundle code here...

index.html

<head>
  <link rel="stylesheet" type="text/css" href="webpack-loaders-css-index-css.html?lang=en">
</head>

after the loader runs it becomes

<head>
  <link rel="stylesheet" type="text/css" href="webpack-loaders-css-index-css?531fdfd0.html?lang=en">
</head>

© JS Foundation and other contributors
Licensed under the Creative Commons Attribution License 4.0.
https://webpack.js.org/loaders/restyle-loader

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部