⚠ Heads up! This module has been deprecated. Have a look at isomorphic-ensure and use raw-loader directly.
node-raw
Make webpack’s raw-loader work in node and iojs.
And that almost for free. The whole thing weighs around 300 bytes minzipped.
Installation
$ npm install node-raw
Usage
- Shim
require
.
const grab = require dirname: __dirname;
- Profit!
// Require modules as you did normally.const Rx = ; // Require text files with *raw-loader*. That’ll now work in node as well!const readme = ;
- Hot tip!
This works well with node-ensure:
if !grabensure grabensure = ;
Caveats
I’m having some weird problems with requiring files directly from node_modules
(like in grab('raw!node-raw/Readme.md)
). For relative files everything works like a charm and can be considered stable.