version-file-webpack-plugin
TypeScript icon, indicating that this package has built-in type declarations

0.2.3 • Public • Published

version-file-webpack-plugin

Generate version infomation file in webpack output folder

test npm

usage

npm i -D version-file-webpack-plugin

# or

yarn add -D version-file-webpack-plugin
# install dependencies
yarn

# build for production with minification
yarn build

# test
yarn test

options

options type default description
output string __version.json file path
absolute boolean false Absolute path of output
data object {} output data
jsonStringify.replacer array null JSON.stringify replacer
jsonStringify.space string|number 2 JSON.stringify space
writeFileOptions object { encoding: "utf-8", flag: "w" } fs.writeFile options

config

// webpack.config.js

const VersionPlugin = require('version-file-webpack-plugin');

module.exports = {
  // ...
  plugins: [
    new VersionPlugin({
      output: '__info/version.txt', // @default `__version.json`
      data: process.env,
    });
  ],
};

nextjs

custom webpack config

// next.config.js

module.exports = {
  webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
    config.plugins.push(
      new versionFile({
        data: process.env,
      })
    );

    return config;
  },
};

.gitignore

+/public/[output]

license

MIT

Readme

Keywords

Package Sidebar

Install

npm i version-file-webpack-plugin

Weekly Downloads

365

Version

0.2.3

License

MIT

Unpacked Size

8.5 kB

Total Files

5

Last publish

Collaborators

  • wangcch