Skip to content

TuurDutoit/require-txt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

require-txt

Require plain text files, like any .js or .json file.

WARNING!

This is a dirty hack and the API this functionality depends on (require.extensions) is deprecated! The module loader API is frozen, so it will probably never be removed, but it may be unstable or have some weird quirks. Also, the number of filesystem calls node.js has to make to require any module grows linearly with the number of registered file extensions!
Do not - I repeat - do not use this in production. You have been warned.

Installation

With NPM:

$ npm install require-txt

Or Yarn:

$ yarn add require-txt

Usage

First, register the handler:

require("require-txt")();

Then, just require your files:

console.log(require("./hello.txt"));
// "Hello, how are you?"

You can pass custom file type extensions:

require("require-txt")("csv");
require("require-txt")(["html", "html5"]);

That's pretty much it.

About

Require plain text files, like any .js or .json file.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors