1.0.1 • Published 12 months ago

update-etag-webpack-plugin v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
12 months ago

update-etag-webpack-plugin


为本次构建生成一个具有时间戳的 json 文件,并输出到静态资源目录中

Install

npm i --save-dev update-etag-webpack-plugin

yarn add --dev update-etag-webpack-plugin

方法属性配置

属性说明类型默认值
name文本内容string-
ignoreMode维护的关键字信息表HighlightKeyWord[]-

Usage


webpack.config.js

  const UpdateEtagWebpackPlugin = require("update-etag-webpack-plugin");

  module.exports = {
      mode: 'production',
      entry:'./src/index.js',
      output: {
          filename: 'index.js',
          path: path.resolve(__dirname, 'dist')
      },
      plugins: [
          new UpdateEtagWebpackPlugin({ name: "release_time" }),
      ]
  }

index.js

  fetch('/release_time.json').then((data)=>{
    const { latest_release_at } = data || {};

    const local_latest_release_at = localStorage.getItem('latest_release_at');
    if(latest_release_at !== local_latest_release_at) {
      // do update
      update()
    }
  });
1.0.1

12 months ago

1.0.0

12 months ago