Skip to content

Latest commit

 

History

History
43 lines (32 loc) · 1.44 KB

README.md

File metadata and controls

43 lines (32 loc) · 1.44 KB

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.