{"id":22224,"library":"rollup-plugin-smart-asset","title":"rollup-plugin-smart-asset","description":"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.","status":"active","version":"2.1.2","language":"javascript","source_language":"en","source_url":"https://github.com/sormy/rollup-plugin-smart-asset","tags":["javascript","rollup-plugin","asset","rebase","url","copy","inline"],"install":[{"cmd":"npm install rollup-plugin-smart-asset","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-smart-asset","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-smart-asset","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required; plugin only works with Rollup bundler","package":"rollup","optional":false}],"imports":[{"note":"Default export only; named import will result in undefined.","wrong":"import { smartAsset } from 'rollup-plugin-smart-asset'","symbol":"smartAsset","correct":"import smartAsset from 'rollup-plugin-smart-asset'"},{"note":"CJS users must access .default due to ESM->CJS interop.","wrong":"const smartAsset = require('rollup-plugin-smart-asset')","symbol":"smartAsset (CommonJS)","correct":"const smartAsset = require('rollup-plugin-smart-asset').default"}],"quickstart":{"code":"import smartAsset from 'rollup-plugin-smart-asset';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    file: 'dist/bundle.js',\n    format: 'esm'\n  },\n  plugins: [\n    smartAsset({\n      url: 'copy',\n      assetsPath: 'assets',\n      publicPath: '/static/',\n      useHash: true,\n      keepName: false,\n      maxSize: 14\n    })\n  ]\n};","lang":"javascript","description":"Copies assets (default .svg,.gif,.png,.jpg) into 'assets/' in output dir, references them with '/static/[hash][ext]'."},"warnings":[{"fix":"Use require('rollup-plugin-smart-asset').default","message":"Default export is not a function in CJS require() – must use .default","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set extensions via include/exclude patterns instead","message":"If using 'include' or 'exclude', the 'extensions' option is ignored","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set maxSize option explicitly to override","message":"Maximum file size for inline mode default is 14 kB (not 10 or 20)","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Replace import { smartAsset } with import smartAsset (or require with .default)","cause":"Using named import instead of default import","error":"Error: The 'rollup-plugin-smart-asset' plugin is not a function"},{"fix":"Use const smartAsset = require('rollup-plugin-smart-asset').default","cause":"CJS require returns an object with .default property","error":"TypeError: smartAsset is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}