1.0.0 • Published 3 years ago

webpack-build-version-file-plugin v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

安装

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)

文件内容序列化方法

1.0.0

3 years ago