grunt-html2str
Minify HTML 2 JavaScript String
Getting Started
This plugin requires Grunt ~0.4.5
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-html2str --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt;
The "html2str" task
Overview
In your project's Gruntfile, add a section named html2str
to the data object passed into grunt.initConfig()
.
grunt;
Options
options.src
Type: String
Default value: ''
html files
options.dest
Type: String
Default value: './'
javascript output path
options.prefix
Type: String
Default value: ''
a string add before the output javascript
options.suffix
Type: String
Default value: ''
a string add after the output javascript
options.type
Type: String
Default value: ''
setting prefix & suffix with special type,
type = 'node'
prefix = 'module.exports = ';suffix = ';';
type = 'cmd'
prefix = 'define(function (require, exports, module) {\n module.exports = ';suffix = ';\n});';
Usage Examples
Default Options
In this example, html file will change into a js file with the same name containing:
"<html>...</html>"
grunt;
Custom Options
In this example, custom prefix and suffix will add to the js file:
{var a="<html>...</html>";};
grunt;
Release History
0.0.1
Initial release.