update-version-popup
v1.2.1
Published
Display an update message at right bottom
Downloads
2
Readme
update-popup
Table of Contents
Features
Check if the current application is the latest version. If not, it reminds you to reload the current page.
Install
yarn add update-version-popup
Usage
popup.txt
You need to set environment variables UPDATE_POPUP_VERSION
, when iteratively updating, modify the variables greater than current value.
Environment variables
# .env
UPDATE_POPUP_VERSION=1.0.0 # Support more. e.g.: 1.0.0.1, 1.0.0.1.1
You may use auto to ignore this.
popup.js
Project configurations:
// nuxt.config.js
const config = {
modules: [
['update-version-popup/nuxt', {auto: true}]
]
}
// vue.config.js
// poi.config.js
// .umirc.ts
const config = {
chainWebpack: config => {
config.plugin('yuwangi-update-popup').use(require('update-version-popup'), [{auto: true}])
}
}
// and remember add import in your App.js
// you may need to ignore IDE's warning
import 'update-version-popup/app/main'
It's so easy.
Options
isProduction
- Type:
boolean
- Default: process.env.NODE_ENV
use to env
publicPath
- Type:
string
- Default:
webpackConfig.output.publicPath
- Reference: webpack publicPath
Use publicPath setting
auto
- Type:
boolean
- Default:
false
to make updated version code automaticly
Note:If true,the environment variable UPDATE_POPUP_VERSION
doesn't work.
versionType
- Type:
'timestamp' | Support more...
- Default:
timestamp
The way of automatically generated version,values:
timestamp
:Using the current timestamp,it looks like this:
1603184005919.0.0
. it was put in the first place to ensure that it would always be bigger than the previous version.Note:this will lose the control of version semantics.
inject
- Type:
boolean
- Default:
true
Does it need to be automatically added to the webpack entry file?
If set false
Need to manually update-version-popup/app/main
Inject it into your code.
When to set this parameter, see Notice.QianKun。
envKey
- Type:
string
- Default:
'UPDATE_POPUP_VERSION'
Key of the environment variable. e.g. process.env.UPDATE_POPUP_VERSION=1.0.0
versionFileName
- Type:
string
- Default:
'update_popup_version.txt'
Version filename.
Notice
QianKun
This plugin automatically generates a common js file and adds it to the webpack entry file,
however, due to the requirement to export lifecycle hooks for the sub-application's entry file.
It is necessary to disable the automatic addition of entry files, with the following adjustments:
Use in sub-applications
Adjust the project configuration file
# nuxt.config.js
const config = {
- modules: ['update-version-popup/nuxt']
+ modules: [['update-version-popup/nuxt'], { inject: false }]
}
# vue.config.js or poi.config.js
const config = {
chainWebpack: config => {
config.plugin('update-popup').use(UpdatePopup, [{
+ inject: false
}])
}
}
Add an entry file in your Sub-application at last
+ import 'update-version-popup/app/main'
Contributing
For those who are interested in contributing to this project, such as:
- report a bug
- request new feature
- fix a bug
- implement a new feature
Please refer to our contributing guide.