<commit_before># Modifier Redirect Webpack plugin

A plugin for webpack that redirects requires to the same resource but with a modifier, if it exists.

## Purpose 

This plugin is meant for systems where you want multiple bundles from the same entry point, but for them to take different files. 
Whether it's for HTML templates, images or changes in CSS. 

## Usage

The usage is a simple addition to `webpack.config.js`:

    var ModifierRedirectPlugin = require('modifier-redirect-webpack-plugin');

    module.exports = {
      ...
      plugins: [
        new ModifierRedirectPlugin("myModifier")
      ]
    }


## Example 

Assuming we have the following file structure in the project: 

    app/
        templates/
            myComponent.html
            myComponent-customer1.html
            myComponent-customer2.html
        index.js

And in the `main.js`: 

    var template = require('./templates/myComponent.html');
    
    document.findElementsByName("body")[0].append(template);
    
then in the `webpack.config.js` we can use it like so:
           
    const VARIATION = "customer1"
    
    var ModifierRedirectPlugin = require('modifier-redirect-webpack-plugin');
    
    module.exports = {
     ...
     plugins: [
       new ModifierRedirectPlugin(VARIATION)
     ]

This will make the `require('templates/myComponent.html')` in `main.js` return the content of `myComponent-customer1.html`.
 
If you change `VARIATION` to `customer2` it will return `myComponent-customer2.html`

And if you change `VARIATION` to `noSuchFile` it will return `myComponent.html`<commit_msg>More changes to README<commit_after># Modifier Redirect Webpack plugin

A plugin for webpack that redirects require statements to the same resource but with a modifier, if it exists.

## Purpose 

This plugin is meant for systems where you want multiple bundles from the same entry point, but for them to take different files. 
Whether it's for HTML templates, images or changes in CSS. 

This can be used for localization, for customer branding changes and more.


## Example 

In the following project structure: 

    app/
        templates/
            myComponent.html
            myComponent-fr.html
            myComponent-he.html

Without the plugin, `require('app/templates/myComponent.html')` will return `myComponent.html`. 
 
But if in `webpack.config.js` we can use the plugin like so:
           
    var ModifierRedirectPlugin = require('modifier-redirect-webpack-plugin');
    
    module.exports = {
     ...
     plugins: [
       new ModifierRedirectPlugin("fr")
     ]

This will make the `require('app/templates/myComponent.html')` return the content of `myComponent-fr.html`.
{'fraction_non_alphanumeric': 0.08095061269959153, 'fraction_numerical': 0.0025993316004456, 'mean_word_length': 2.991111111111111, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2572852', 'n_tokens_mistral': 743, 'n_tokens_neox': 709, 'n_words': 269}