modify-loader
==================
LoDash templates loader for webpack. The compiled string returned.
Installation
npm install modify-loader --save-dev
Usage
file.css
var options = JSON;var value = JSON; var template = ;// => returns the compiled string with lodash templating method.console;// body{// background-color: #000;// }
Config
This webpack config can load arbitrary text files.
var options = JSON; moduleexports = module: loaders: test: /\.css$/ loader: "style!css!modify?options=" + options ;
is equivalent to
var template = _color: '#000';
The
options
is optional, and the same as lodash-template-options Thevalue
will be used as interpolated data
Special Case
Since JSON
doesn't support regular expression, so it's not possible to pass a RegExp
directly, which means for following options, we need workaround for them:
- escape
- evaluate
- interpolate
For solving this issue, we pass Object
which contains pattern
and attributes
as following:
var options = JSON; var value = JSON; moduleexports = module: loaders: test: /\.css$/ loader: "style!css!modify?options=" + options + '&value=' + value ;