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

hashed-map-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hashed-map-webpack-plugin

Map the filepaths of files output by a webpack compilation from their hashed version to their unhashed version.

  • 0.0.13
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

hashed-map-webpack-plugin

This plugin maps the filepaths of files output by a webpack compilation from their hashed version to their unhashed version.

Example output

{
  "/site.js": "https://assets.my-site.com/site.123123.js",
  "/images/edison.jpg": "https://assets.my-site.com/images/edison.123123.jpg",
  "/site.css": "https://assets.my-site.com/site.123123.css"
}

Installation

npm install hashed-map-webpack-plugin --save-dev

Configuration

In your webpack config include the plug-in. And add it to your config:

var path = require('path')
var HashedMapPlugin = require('hashed-map-webpack-plugin')

module.exports = {
    plugins: [HashedMapPlugin(), ...]
    output: {
        path: path.join(__dirname, '../www'),
        filename: '[path].[name].[hash].js',
        publicPath: 'https://assets.my-site.com/'
    },
    ...
}

Options

You can pass the following options:

exclude

Regex to match for excluded content.

filepath

Where to save the JSON file output by the plugin.

Optional. static-assets.json by default.

preset

If you wish you can preset the map to a JavaScript object. This can be useful for adding in metadata or mappings outside the webpack compilation scope.

Note: Any conflicting filepaths in the preset will be overridden during compilation.

stripHash

A function used to strip the hash from the filepath. The default function splits the filename using the dot (.) character and rejoins minus the last but one part, e.g:

function stripHash(filepath) {
    var parts = filepath.split('.');
    parts.splice(parts.length - 2, 1);
    return parts.join('.');
}

stripHash('/site.123123.js')

> '/site.js'

Testing

To test the plugin run:

npm test

Keywords

FAQs

Package last updated on 22 Feb 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