https://github.com/wangcch/version-file-webpack-plugin
Generate version infomation file in webpack output folder
https://github.com/wangcch/version-file-webpack-plugin
Last synced: 18 days ago
JSON representation
Generate version infomation file in webpack output folder
- Host: GitHub
- URL: https://github.com/wangcch/version-file-webpack-plugin
- Owner: wangcch
- License: mit
- Created: 2021-04-27T06:57:00.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2022-01-12T05:36:10.000Z (over 4 years ago)
- Last Synced: 2025-01-27T14:51:08.994Z (over 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 156 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# version-file-webpack-plugin
Generate version infomation file in webpack output folder
[](https://github.com/wangcch/version-file-webpack-plugin/actions/workflows/main.yml)
[](https://www.npmjs.com/package/version-file-webpack-plugin)
[](https://github.com/wangcch/version-file-webpack-plugin/blob/main/LICENSE)
## usage
```shell
npm i -D version-file-webpack-plugin
# or
yarn add -D version-file-webpack-plugin
```
```shell
# install dependencies
yarn
# build for production with minification
yarn build
# test
yarn test
```
## 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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) |
| jsonStringify.space | string\|number | 2 | JSON.stringify [space](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) |
| writeFileOptions | object | `{ encoding: "utf-8", flag: "w" }` | fs.writeFile options |
## config
```js
// webpack.config.js
const VersionPlugin = require('version-file-webpack-plugin');
module.exports = {
// ...
plugins: [
new VersionPlugin({
output: '__info/version.txt', // @default `__version.json`
data: process.env,
});
],
};
```
### nextjs
[custom webpack config](https://nextjs.org/docs/api-reference/next.config.js/custom-webpack-config)
```js
// next.config.js
module.exports = {
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
config.plugins.push(
new versionFile({
data: process.env,
})
);
return config;
},
};
```
`.gitignore`
```diff
+/public/[output]
```
## license
[MIT](./LICENSE)