add-asset-webpack-plugin

v3.0.0
Dynamically add an asset to the Webpack graph
webpack-plugin webpack add generate create make asset file

add-asset-webpack-plugin

Dynamically add an asset to the Webpack graph

Install

npm install add-asset-webpack-plugin

Usage

import AddAssetPlugin from 'add-asset-webpack-plugin';

export default {
    // …
    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

npm i add-asset-webpack-plugin

Metadata

  • MIT
  • >=18
  • Sindre Sorhus
  • released 4/30/2024

Downloads

Maintainers