webpack-build-version-file-plugin

1.0.0 • Public • Published

安装

npm install --save-dev webpack-version-file-plugin

使用

webpack.config.js

const VersionFilePlugin = require('webpack-version-file-plugin');

module.exports = {
  // ...
  plugins: [new VersionFilePlugin()],
};

默认会生成一个 version.json 的文件,内容如下:

{
  "hash": "3c84397d21aef9fe86528a5b12a8bbbe"
}

API

// webpack.config.js

module.exports = {
  // ...
  plugins: [
    new VersionFilePlugin({
      filePath: 'version.json',
      serialize: function (json) {
        return JSON.stringify(json, null, 2);
      },
    }),
  ],
};

options.filePath

Type: String
Default: version.json

生成文件路径

options.serialize

Type: Function(Object): string
Default: (json) => JSON.stringify(json, null, 2)

文件内容序列化方法

Readme

Keywords

none

Package Sidebar

Install

npm i webpack-build-version-file-plugin

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

5.6 kB

Total Files

8

Last publish

Collaborators

  • 463393074