asset-require-hook
A require hook for importing asset files during runtime
Last updated 5 years ago by aribouius .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install asset-require-hook 
SYNC missed versions from official npm registry.

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
})

Current Tags

  • 1.2.0                                ...           latest (3 years ago)

5 Versions

  • 1.2.0                                ...           3 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.2                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 2
This Week 2
This Month 378
Last Day 6
Last Week 367
Last Month 1,267
Dependencies (3)
Dev Dependencies (7)

Copyright 2014 - 2016 © taobao.org |