Socket
Socket
Sign inDemoInstall

asset-require-hook

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asset-require-hook

A require hook for importing asset files during runtime


Version published
Weekly downloads
2.7K
decreased by-3.1%
Maintainers
1
Weekly downloads
 
Created
Source

asset-require-hook

A require hook for importing asset files during runtime.

Features

Allows files required by node that match a given set of extensions to be returned as either a data URI, or a custom filename. Meant to be used in conjunction with file-loader or url-loader when building universal apps.

Requirements

Using this tool requires Node.js v0.12.x or higher.

Installation

$ npm i --save asset-require-hook

Usage

Attach the require hook to the desired file extensions using the extensions parameter.

require('asset-require-hook')({
  extensions: ['jpg']
})

// const image = require('./icon.jpg');

The require hook accepts the same parameters as the file-loader.

require('asset-require-hook')({
  extensions: ['jpg'],
  name: '[hash].[ext]'
})

To enable data URI's use the limit parameter, and optionally any other parameters used by the url-loader.

require('asset-require-hook')({
  extensions: ['woff'],
  mimetype: 'application/font-woff',
  limit: 10000
})

Keywords

FAQs

Package last updated on 21 Sep 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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc