Skip to content

kaipaysen/webpack-version-bump-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

!!! This Plugin still requires quite some work !!!

webpack-version-bump-plugin

Plugin to write Version String From package.json into Source Files

Install

    npm install -D @sekp/webpack-version-bump-plugin

Setup in webpack.config.js

const { WebpackVersionBumpPlugin } = require('@sekp/webpack-version-bump-plugin');
//...
plugins: [
    //...
    new WebpackVersionBumpPlugin({
        package: path.resolve(__dirname, "package.json"),
        places: [
            {
                filename: path.resolve(__dirname, "public/serviceworker.js"),
                mode: 'after',
                find: /^var CACHE_NAME =(.*)$/m,                
                replace: (newVersion) => `var CACHE_NAME = "${newVersion}";`
            }, {
                filename: path.resolve(__dirname, "package.json"),
                mode: 'before',
                find: /^\s*\"version\":.*$/m,
                replace: (newVersion) => `  "version": "${newVersion}",`
            }, {
                filename: path.resolve(__dirname, "package-lock.json"),
                mode: 'before',
                find: /^\s*\"version\":.*$/m,
                replace: (newVersion) => `  "version": "${newVersion}",`
            }
        ]
    })
]

About

Plugin to write Version Strings into Source Files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published