npm.io
1.0.0 • Published 5 years ago

webpack-build-version-file-plugin

Licence
ISC
Version
1.0.0
Deps
0
Size
5 kB
Vulns
0
Weekly
0

安装

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)

文件内容序列化方法