https://github.com/wjtools/version-webpack-plugin
https://github.com/wjtools/version-webpack-plugin
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/wjtools/version-webpack-plugin
- Owner: wjtools
- License: mit
- Created: 2021-03-17T06:37:06.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-04-01T03:14:34.000Z (almost 4 years ago)
- Last Synced: 2025-03-08T15:48:31.834Z (10 months ago)
- Language: JavaScript
- Size: 30.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

@wjtools/version-webpack-plugin
一个简易的 webpack 版本号自动更新插件
安装
首先,您需要安装 `@wjtools/version-webpack-plugin`:
```console
$ yarn add @wjtools/version-webpack-plugin --save-dev
```
然后将插件添加到您的 `webpack` 配置。例如:
**vue.config.js**
```js
configureWebpack: config => {
if (isProd) {
// 自动更新 package.json 中的版本号
const VersionWebpackPlugin = require('@wjtools/version-webpack-plugin')
config.plugins.push(
new VersionWebpackPlugin({
// file: 'package.json', // 指定版本号所在文件,默认:'package.json'
// version: '1.0.0', // 指定版本号,默认取 file 指定文件中的版本号
// mode: 'increment', // 更新模式:increment-递增(默认);timestamp-时间戳
}),
)
}
},
```
使用
每次打包会生成新的递增的版本号,直接导入即可使用,例如:
**main.js**
```js
import { version } from '../package'
```
***版本号兼容 `1.x.x`、`x.x`、`x` 等写法***