Generate version infomation file in webpack output folder
npm install version-file-webpack-pluginGenerate version infomation file in webpack output folder



``shell
npm i -D version-file-webpack-plugin
yarn add -D version-file-webpack-plugin
`
`shellinstall dependencies
yarn
options
| options | type | default | description |
| ---------------------- | -------------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| output | string | \_\_version.json | file path |
| absolute | boolean | false | Absolute path of output |
| data | object |
{} | output data |
| jsonStringify.replacer | array | null | JSON.stringify replacer |
| jsonStringify.space | string\|number | 2 | JSON.stringify space |
| writeFileOptions | object | { encoding: "utf-8", flag: "w" } | fs.writeFile options |config
`js
// webpack.config.jsconst VersionPlugin = require('version-file-webpack-plugin');
module.exports = {
// ...
plugins: [
new VersionPlugin({
output: '__info/version.txt', // @default
__version.json
data: process.env,
});
],
};
`$3
`js
// next.config.jsmodule.exports = {
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
config.plugins.push(
new versionFile({
data: process.env,
})
);
return config;
},
};
`.gitignore`diff
+/public/[output]
``