Skip to content

edonet/var-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

var-loader

string variable replace loader for webpack

Installation

npm

$ npm install var-loader

or yarn

$ yarn add var-loader

Usage

// webpack.config.js
module.exports = {
	...
    module: {
        rules: [{
            test: /\.tpl$/,
            use: [
                'raw-loader',
                {
                    loader: 'var-loader',
                    options: {

                        // the string will to replaced as regexp
                        find: /\$\{(.*?)\}/g

                        // the replace function as a value to return
                        replace: (key, val) => ['prefix', key, val].join('-'),

                        // the replace variable map
                        data: {
                            name: 'value'
                        }
                    }
                }
            ]
        }]
    }
};

About

replace $var loader for webpack

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published