Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

extract-hash-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

extract-hash-webpack-plugin

Extract webpack `compiler hash` to generate `version.json` file after build in the `dest` directory.

  • 1.1.3
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

extract-hash-webpack-plugin

Extract webpack compiler hash to generate version.json file after build in the dest directory.

Options

You can pass some configuration options to ExtractHashWebpackPlugin. Allowed values are as follows:

  • filename: Version file name. Default to version.json.
  • hashLength: Substring length of compiler hash. Default to value 'normal' which means the whole hash value itself. You can pass a number to get a substring of it. Or pass string 'full' to get value of fullHash.
  • dest: Version file save path. Default to process.cwd(). Will do mkdir if path doesn't exist.
  • fn: A function to customize content format of version file to be generated. Default to return a json string of hash with the key version.

Example

Generate file ver.json in directory path.resolve(process.cwd(), 'prd').

import ExtractHashWebpackPlugin from 'extract-hash-webpack-plugin';

var webpackConfig = {
  entry: 'main.js',
  output: {
    filename: '[name]-[hash:8].js',
    publicPath: '/js',
  },
  plugins: [
    new ExtractHashWebpackPlugin({
      dest: 'prd',
      filename: 'ver.json',
      hashLength: 8,
    }),
    new ExtractHashWebpackPlugin({
      dest: 'prd',
      filename: 'ver.xml',
      hashLength: 8,
      fn: hash => `<xml><version>${hash}</version></xml>`
    })
  ]
};

Contents of ver.json:

{
  "version": "[hash:8]"
}

Contents of ver.xml:

<xml>
  <version>
    [hash:8]
  </version>
</xml>

FAQs

Package last updated on 11 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc