alp-rollup-plugin-config
raw JSON → 4.0.2 verified Mon Apr 27 auth: no javascript
Rollup plugin to transform YAML configuration files using copy and YAML transform during the build process. v4.0.2 requires Node >=22.18.0, supports Rollup 2, 3, and 4, and includes full TypeScript type definitions. It is part of the alp ecosystem but can be used standalone. The plugin copies YAML files and optionally applies transformations, enabling dynamic config injection in Rollup bundles.
Common errors
error Error: Plugin 'alp-rollup-plugin-config' requires a peer of rollup@^2.64.0 || ^3.0.0 || ^4.0.0 but none is installed. ↓
cause Missing Rollup peer dependency.
fix
Run npm install rollup --save-dev to install Rollup.
error TypeError: alpRollupPluginConfig is not a function ↓
cause Using CommonJS require with ESM-only package.
fix
Change to ES module import syntax: import configPlugin from 'alp-rollup-plugin-config'.
error Error: Node version 18.0.0 is not supported. Please use Node >=22.18.0. ↓
cause Node version too low for v4.x.
fix
Upgrade Node to >=22.18.0.
Warnings
breaking v4.0.0 drops support for Node <22.18.0 and Rollup <2. ↓
fix Upgrade Node to >=22.18.0 and Rollup to >=2.
deprecated v3.x series is no longer maintained; upgrade to v4. ↓
fix Update to ^4.0.0 and adjust Node version.
gotcha Plugin must be used in Rollup's transform hook context; ensure config files are in the correct location relative to the working directory. ↓
fix Use absolute paths or ensure relative paths resolve from the project root.
Install
npm install alp-rollup-plugin-config yarn add alp-rollup-plugin-config pnpm add alp-rollup-plugin-config Imports
- default wrong
const alpRollupPluginConfig = require('alp-rollup-plugin-config')correctimport alpRollupPluginConfig from 'alp-rollup-plugin-config' - alpRollupPluginConfig
import { alpRollupPluginConfig } from 'alp-rollup-plugin-config' - PluginOptions wrong
const { PluginOptions } = require('alp-rollup-plugin-config')correctimport type { PluginOptions } from 'alp-rollup-plugin-config'
Quickstart
import configPlugin from 'alp-rollup-plugin-config';
import { defineConfig } from 'rollup';
export default defineConfig({
input: 'src/index.js',
plugins: [
configPlugin({
files: ['config.yaml', 'config.prod.yaml'],
transform: (content) => {
const d = JSON.parse(content);
d.appVersion = process.env.APP_VERSION ?? 'dev';
return JSON.stringify(d);
},
copy: true
})
],
output: {
dir: 'dist',
format: 'esm'
}
});