Socket
Book a DemoInstallSign in
Socket

contents-loader

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

contents-loader

Webpack loader to import the contents of a directory.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

contents-loader Build Status

Webpack loader to import the contents of a directory.

For a directory structure like:

└── abc
    ├── foo.js
    ├── bar.js
    ├── baz.js
    ├── somethingElse.txt
    └── styles.css

contents-loader!./abc/ generates code like:

import * as _0 from "./abc/foo.js";
import * as _1 from "./abc/bar.js";
import * as _2 from "./abc/baz.js";
export default { "foo.js": _0, "bar.js": _1, "baz.js": _2 };

If you're using vanilla Webpack, this loader has little advantage over the built-in require.context('./abc', false, /\.js$/). If, however, you're using webpack-rollup-loader or similar, require.context will only be processed by Webpack, resulting in suboptimal code generation.

Installation

npm install --save-dev contents-loader

Usage

// trailing slash is important
import modules from 'contents-loader!./path/to/directory/';

// use the `match` option to specify which files to import
// (defaults to `/\.js$/i`)
import images from 'contents-loader?match=\\.png$!./path/to/images/';

Keywords

webpack

FAQs

Package last updated on 03 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.