Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
A

add-asset-webpack-plugin

> 包管理
Open source

Dynamically add an asset to the Webpack graph

99 stars0 likes3 views
WebsiteGitHub

About

Dynamically add an asset to the Webpack graph

add-asset-webpack-plugin

Dynamically add an asset to the Webpack graph

Install

bash
npm install add-asset-webpack-plugin

Usage

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

Asset source or a function that returns the asset source.

If a function, it will receive the compilation instance.

FAQ

Can I import the dynamically created files?

No. This plugin creates assets in the output directory, not importable modules. For virtual modules that can be imported, use webpack-virtual-modules instead.

Related

  • node-env-webpack-plugin - Simplified NODE_ENV handling
  • add-module-exports-webpack-plugin - Add module.exports for Babel and TypeScript compiled code

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScriptjavascriptnodejsnpm-packagewebpack

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category包管理
PricingOpen source

> Related tools

N
npm
Node.js 默认包管理器
P
pnpm
高效节省磁盘的 Node 包管理器
I
is-gif
Check if a Buffer/Uint8Array is a GIF image