npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-cli-plugin-generate-build-id

v0.2.0

Published

Automatically generates build_id after production compiled

Downloads

14

Readme

vue-cli-plugin-generate-build-id

Automatically generates integer build_id after production compiled

在编译生产环境的项目后自动生成 Build ID

支持普通网页项目和 Electron 项目

Support common Vue web project and Electron app project

安装 Installation

    npm i vue-cli-plugin-generate-build-id

or

    yarn add -D vue-cli-plugin-generate-build-id

功能 Features

安装插件后的首次编译时会在项目的根目录建立 version.json

The first time you build the project for production, the plugin will create version.json in the root dir of the project.

version.json

{
    "version" : "1.0", // `version` in `packages.json`
    "build_id": 1,
    "total_build": 1,
}

开发环境 Development mode

你可以在项目中通过调用 process.env.VUE_APP_VERSION 获取到当前的版本号。

You can use process.env.VUE_APP_VERSION to get the current version of the package.json in your project.

生产环境 Production mode

可通过 process.env.VUE_APP_VERSION 获取到当前的版本号 可通过 process.env.VUE_APP_BUILD_ID 获取当前版本的 build_id 可通过 process.env.VUE_APP_TOTAL_BUILD 获取历史编译次数 total_build

Use process.env.VUE_APP_VERSION to get the current version of the package.json in your project. Use process.env.VUE_APP_BUILD_ID to get the current build_id Use process.env.VUE_APP_TOTAL_BUILD to get the current total build times (total_build)

项目编译完成后,插件会将根目录下的 version.json 复制到产物的根目录。

注意:修改 packages.json 内的 version 的值使 build_id 清零, 删除根目录的 version.json 则将 build_idtotal_build 清零。

Caution:change the value of verison in package.json will reset the build_id in version.json, delete the version.json in project root will reset build_id and total_build.

生产环境检测版本文件 Check version.json in production mode

router.beforeEach((to, from, next) => {

    ...
    if (process.env.NODE_ENV === 'production') {
        axios.get('/version.json?' + Date.now()).then(r => {
            if (!(process.env.VUE_APP_VERSION === r.data.version
                && Number(process.env.VUE_APP_BUILD_ID) === r.data.build_id)) {

                // 发现新版本后的业务逻辑
                // verison.json changed
                // ...
            }
        })
    }
    ...
}

LICENSE

MIT