grunt-resify

Access static text resources like HTML and XML in the browser after building with Browserify

npm install grunt-resify
2 downloads in the last week
9 downloads in the last month

grunt-resify

Access static text resources like HTML and CSS in Javascript

What It Do

Say you've got some files like this:

src/
    views/
        layout.html
        page.html
    config/
        setup.xml
        routes.xml
    main.js
    ...

And a grunt step like so:

resify: {
    all: {
        src: ['src/**/*.{html,xml}'],
        dest: 'src/R.js'
    }
}

Running grunt resify will result in a generated R.js file. Now in your Javascript you can do this:

var R = require('./R');

// Use HTML files
document.body.innerHTML = R('views/page.html');

// XML files are parsed
R('config/setup.xml').childs.each(function(c) {
    // ...
});

Getting Started

This plugin requires Grunt ~0.4.1

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-resify --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-resify');
npm loves you