exclude-extensions-from-require

1.0.1 • Public • Published

exclude-extensions-from-require

Exclude files being required by extension.

The use-case for this is when you are sharing code for Node and the browser. You end up using Webpack or Browserify to bundle the requires together. They both can support including files that aren't JavaScript. For example, Webpack allows you to include CSS files which are then outputted into a single CSS file.

On Node, the default is to load these files as JavaScript which will cause an error. In your Node app, you can use this module to tell Node to simple ignore those files.

Usage

const excludeExtensionsFromRequire = require('exclude-extensions-from-require');
excludeExtensionsFromRequire(['scss', 'css']);
 
//...
require('reset.css'); // Nothing happens
 

Readme

Keywords

Package Sidebar

Install

npm i exclude-extensions-from-require

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • seamusleahy