Registry / devops / rollup-plugin-smart-asset

rollup-plugin-smart-asset

JSON →
library2.1.2jsnpmunverified

Rollup plugin for processing assets (rebase, inline or copy) referenced from JavaScript/TypeScript code. Currently at version 2.1.2, with a stable release cadence. Key differentiators: supports three modes (rebase, inline, copy), keepImport for bundling libraries, custom hash algorithms (including MetroHash and xxHash), and full micromatch pattern support for include/exclude. Unlike rollup-plugin-url or @rollup/plugin-url, it prioritizes seamless config reuse with postcss-smart-asset and offers detailed hash options.

npm install rollup-plugin-smart-asset
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-SMAR
R
rollup-plugin-smart-asset
devopsjavascriptv2.1.2
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

smartAsset
✓ import smartAsset from 'rollup-plugin-smart-asset'
✗ import { smartAsset } from 'rollup-plugin-smart-asset'
Default export only; named import will result in undefined.
smartAsset (CommonJS)
✓ const smartAsset = require('rollup-plugin-smart-asset').default
✗ const smartAsset = require('rollup-plugin-smart-asset')
CJS users must access .default due to ESM->CJS interop.

Copies assets (default .svg,.gif,.png,.jpg) into 'assets/' in output dir, references them with '/static/[hash][ext]'.

import smartAsset from 'rollup-plugin-smart-asset'; export default { input: 'src/index.js', output: { file: 'dist/bundle.js', format: 'esm' }, plugins: [ smartAsset({ url: 'copy', assetsPath: 'assets', publicPath: '/static/', useHash: true, keepName: false, maxSize: 14 }) ] };
Debug
Known issues
gotchaDefault export is not a function in CJS require() – must use .default
fix
Use require('rollup-plugin-smart-asset').default
affects: >=1.0.0
gotchaIf using 'include' or 'exclude', the 'extensions' option is ignored
fix
Set extensions via include/exclude patterns instead
affects: >=1.0.0
gotchaMaximum file size for inline mode default is 14 kB (not 10 or 20)
fix
Set maxSize option explicitly to override
affects: >=1.0.0
Errors
Common errors & fixes
Error: The 'rollup-plugin-smart-asset' plugin is not a function
Using named import instead of default import
fix
Replace import { smartAsset } with import smartAsset (or require with .default)
TypeError: smartAsset is not a function
CJS require returns an object with .default property
fix
Use const smartAsset = require('rollup-plugin-smart-asset').default
Upgrade
Version history
2.1.2latest on npm
Audit
Dependencies
rolluprequiredPeer dependency required; plugin only works with Rollup bundler
Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
rollup-plugin-smart-asset — npm install rollup-plugin-smart-asset · libregistry