Skip to content

A rollup plugin to write the current version from package.json into a file during the build process

License

Notifications You must be signed in to change notification settings

binary-butterfly/rollup-plugin-version-file

Repository files navigation

rollup plugin version file

Coverage Status

This is a very small rollup plugin to save the current version from your package.json to a static file during the build process.

Usage

First install the plugin npm i --save-dev @binary-butterfly/rollup-plugin-version-file.
Then, in your rollup config add it to the plugins array:

import versionFile from '@binary-butterfly/rollup-plugin-version-file';

export default {
    // ... other config
    plugins: [
        // ... other plugins
        versionFile({
            'outputPath': './public/version',
            'packageFilePath': './package.json',
            'log': true,
        })
    ]
    // ... other config
}

The config parameters given in that example are the defaults, so if you want to use these settings, you may forego providing a value for them.

Config parameters

  • outputPath: Where to store the version file, relative to your project root directory
  • packageFilePath: Where to find your package.json file, relative to your project root directory
  • log: If you want the plugin to log what it wrote once it is done

Vite

Vite uses rollup internally for production builds. To use this plugin within vite, all you have to do is add the above configuration within your vite config's build.rollupOptions.

About

A rollup plugin to write the current version from package.json into a file during the build process

Resources

License

Stars

Watchers

Forks

Packages

No packages published