close

  menu      DavidRodenas
CONTACT  

Stringify browserify transform

It allow to require files as plain strings and optionally minimizes them.


$ npm i -D stringify
transforms.push(['stringify', {'extensions': [ '.html' ], "minify": true}])
var tpl = require('./my.tpl.html');

Overview

When it encounters an expression like:

var tpl = require('./my.tpl.html');

and a template like:

<h1>My template</h1>
Does {{ cool }} stuff.

it transform the html file into a javascript entry point like:

module.exports = "<h1>My template</h1>\nDoes {{ cool }} stuff.";

## Other considerations

Be careful with html minification. Make sure that the same values are applied to development and production configuration. Some spaces may modify the page layout.

Minification options are specified here.