Skip to content

git-decadent/replace-resources-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published