var-loader
v1.0.3
Published
string variable replace loader for webpack
Downloads
5
Readme
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'
}
}
}
]
}]
}
};