An open API service indexing awesome lists of open source software.

https://github.com/wjtools/version-webpack-plugin


https://github.com/wjtools/version-webpack-plugin

Last synced: 9 months ago
JSON representation

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` 等写法***