string loader for webpack
webpack loader: resource file transform to string
Installation
npm install string-loader --save-dev
Usage
webpack.config setting
loaders: test: /\.[name]$/ loader: "string"
Example 1: html transform to string template
webpack.config
loaders: test: /\.html$/ loader: "string"
list.tpl.html
<ul><% forvar i in list %><li><%= listitext %></li><% %></ul>
list.js
var Template =TPL = ;var html =;console; //html: '<ul><li>option1</li><li>option2</li></ul>'
Example 2: josn transform to string template
webpack.config
loaders: test: /\.html|\.json$/ loader: "string"
data.json
"text": "first""value": "first""text": "second""value": "second"
index.js
var str = ;var json = JSON;console; //json: [{"text": "first","value": "first"},{"text": "second","value": "second"}]