block-loader

A webpack loader for doing generic block-processing. You provide the delimiters and processor, block-loader will find your data and pass it through your processor.

Install

npm install block-loader

Write your own block loader

var blockLoader = require('block-loader');

var options = {

start: '...',

end: '...',

preprocessors: [

function(content) { ...; return content; },

...

],

process: function(content) {

...

return content;

}

};

module.exports = blockLoader(options);

start and end are delimiter strings for you data block, preprocessors is optional and takes an array of function(content).

Example: write real code in "pre" elements

Say you need to write real programming code in <pre> elements, and you want to just write code, not hand-craft every html entity for less than or ampersand symbols just so your Webpack/React build won't bread on them.

Let's just write a quick and easy loader that'll fix those things for us: