rollup-copy-transform-css

raw JSON →
2.2.0 verified Mon Apr 27 auth: no javascript

Rollup plugin utility for transforming CSS files during copy operations with rollup-plugin-copy. Current stable version is 2.2.0, released November 2025, with support for Rollup 2, 3, and 4. Provides CSS minification via cssnano or esbuild, stylesheet and asset inlining via postcss-import and postcss-url, and custom PostCSS plugin pipelines. Key differentiators: supports both PostCSS and esbuild engines for fast processing, integrates seamlessly with rollup-plugin-copy targets, and offers source map generation. Requires Node.js 18+ as of v2.0.0.

error Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
cause Using require() on this package which is ESM-only since v2
fix
Use dynamic import: const { createTransform } = await import('rollup-copy-transform-css');
error TypeError: createTransform is not a function
cause Importing default export incorrectly instead of named export createTransform
fix
Use import { createTransform } from 'rollup-copy-transform-css'
error Error: rollup-plugin-copy is not installed
cause Missing required peer dependency rollup-plugin-copy
fix
Install rollup-plugin-copy alongside this package: npm i -D rollup-plugin-copy
breaking Node.js 18 is required
fix Upgrade Node.js to version 18 or later
breaking ESM-only: no CommonJS support
fix Use import syntax instead of require; set type: 'module' in package.json
gotcha Experimental esbuild engine may produce different output than PostCSS
fix Set minify: { fast: true } or inline: { fast: true } to use esbuild; test output carefully
gotcha Source map generation may be silently ignored if not explicitly configured
fix Ensure map option is set to boolean or object in createTransform or transform call
npm install rollup-copy-transform-css
yarn add rollup-copy-transform-css
pnpm add rollup-copy-transform-css

Basic Rollup config using rollup-plugin-copy with transform that minifies CSS and generates an external source map.

import copy from 'rollup-plugin-copy';
import { createTransform } from 'rollup-copy-transform-css';

const transformCss = createTransform({
  inline: false,
  minify: true,
  map: { inline: false }
});

export default {
  input: 'src/index.js',
  output: {
    file: 'dist/bundle.js',
    format: 'iife'
  },
  plugins: [
    copy({
      targets: [
        {
          src: 'src/styles/main.css',
          dest: 'dist/styles',
          transform: transformCss
        }
      ]
    })
  ]
};