replace-resources-plugin

0.0.4 • Public • Published

Replace Resources Plugin

npm MIT License

A webpack plugin to copy data from the source file to a target one

Installation

npm install --save-dev replace-resources-plugin

Usage

Add the plugin to your webpack config. For example:

webpack.config.js

const ReplaceResourcesPlugin = require('replace-resource-plugin');
 
const webpackConfig = {
    plugins: [
        new ReplaceResourcesPlugin(/\.src\.js/, /\.dist\.js/),
    ],
};
 
module.exports = webpackConfig;

Parameters

The plugin requires two parameters:

new ReplaceResourcesPlugin(sourceRegExp, distRegExp [, options]),

Which must be regular expressions and mean to be used to detect a source file of data and a destination file where the data must be copied to. The destination regular expression is applied firstly if it matches the file name. If this condition is true then the source regular expression is used to find whether there is the file matching it in the current working directory. If the source file is found the data of it is being copied to a destination one.

  • sourceRegExp: RegExp
  • distRegExp: RegExp
  • options: Object - optional
    • replaceDistFileIfHMR: Boolean, default: false - defines if the plugin must process changes that are happening due to Hot Module Replacement on a destination file. By default changes are happening in the runtime and detected by HMR will be ignored in order to avoid infinite loop of replacmemts between source and destination files.

Package Sidebar

Install

npm i replace-resources-plugin

Weekly Downloads

1

Version

0.0.4

License

MIT

Unpacked Size

7.17 kB

Total Files

5

Last publish

Collaborators

  • oh_hi_npm!