0.0.4 • Published 8 years ago

virtual-file-loader v0.0.4

Weekly downloads
2
License
ISC
Repository
github
Last release
8 years ago

virtual-file-loader

Load a virtual file from a buffer using webpack

Basic Usage

require("virtual-file-loader?src=...&file=...!");

Where src is the HEX encoded source of the module, and fileis the virtual filename for the file.

Example

Lets take the following code

module.exports = "Hello From Virtual";

By encoding it, we have:

6D6F64756C652E6578706F727473203D202248656C6C6F2046726F6D205669727475616C223B

So our require will be like

const virtual = require("virtual-file-loader?src=6D6F64756C652E6578706F727473203D202248656C6C6F2046726F6D205669727475616C223B&file=my-virtual-file.js");
// Expected output is "Hello From Virtual"
console.log( virtual );

Notes

The file param is essential because it will be used to resolve the loaders, if you want to create a css file, just use something like file=my-virtual-file.css