add-asset-webpack-plugin
Dynamically add an asset to the Webpack graph
Last updated 6 years ago by sindresorhus .
MIT · Repository · Bugs · Original npm
$ cnpm install add-asset-webpack-plugin 
SYNC missed versions from official npm registry.

add-asset-webpack-plugin Build Status

Dynamically add an asset to the Webpack graph

Install

$ npm install add-asset-webpack-plugin

Usage

const AddAssetPlugin = require('add-asset-webpack-plugin');

module.exports = {
	// …
	plugins: [
		new AddAssetPlugin('file.js', `
			console.log('This is a dynamically created file');
		`)
	]
};

API

AddAssetPlugin(filePath, source)

filePath

Type: string

Relative file path for the asset.

source

Type: string | (compilation => string | Promise<string>)

Asset source or a function that returns the asset source.

If a function, it will receive the compilation instance. And if the function returns a promise, it will be awaited.

Related

License

MIT © Sindre Sorhus

Current Tags

  • 1.0.0                                ...           latest (6 years ago)

1 Versions

  • 1.0.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (5)
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org