{"id":22278,"library":"rollup-plugin-variables","title":"rollup-plugin-variables","description":"A Rollup plugin that replaces custom markers (e.g., [[VARIABLE]]) in source files with values from a separate variables file (JS, JSON, or TXT). Stable version 0.1.1. Low activity; last release in 2019. Key differentiator: allows externalizing environment-specific values without a full-fledged env replacement plugin. Limited to rollup.","status":"maintenance","version":"0.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/andrelmlins/rollup-plugin-variables","tags":["javascript","rollup","plugin","variables"],"install":[{"cmd":"npm install rollup-plugin-variables","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-variables","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-variables","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency - plugin requires Rollup to function","package":"rollup","optional":false}],"imports":[{"note":"ESM default import is only supported; CommonJS require may work if using a bundler","wrong":"const variables = require('rollup-plugin-variables')","symbol":"default","correct":"import variables from 'rollup-plugin-variables'"},{"note":"Named export does not exist; use default import","wrong":"import { variables } from 'rollup-plugin-variables'","symbol":"variables","correct":"import variables from 'rollup-plugin-variables'"},{"note":"No dedicated type exports; types inferred from Rollup","wrong":"","symbol":"None (type import)","correct":"import type { RollupOptions } from 'rollup'; import variables from 'rollup-plugin-variables';"}],"quickstart":{"code":"// rollup.config.js\nimport variables from 'rollup-plugin-variables';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    file: 'dist/bundle.js',\n    format: 'iife'\n  },\n  plugins: [\n    variables({\n      fileName: 'env.js',\n      format: 'js',\n      marker: '[[]]'\n    })\n  ]\n};","lang":"javascript","description":"Configures Rollup to replace [[variables]] with values from env.js during build."},"warnings":[{"fix":"Ensure source files use [[VARIABLE_NAME]] syntax, or configure marker option.","message":"Default marker is [[]]; double brackets required.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use module.exports = { KEY: 'value' } in .js file; for .json use JSON object directly.","message":"Variables file must export an object (module.exports = ...) when format is 'js'.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Consider migrating to @rollup/plugin-replace or similar.","message":"Plugin is in maintenance mode; no updates expected.","severity":"deprecated","affected_versions":">=0.1.0"},{"fix":"Use flat variable names without nested brackets.","message":"Nested markers (e.g., [[[VAR]]]) not supported; will cause undefined replacement.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Ensure env.js exists in the same directory as rollup.config.js or provide absolute path via fileName option.","cause":"Variables file path is resolved relative to rollup.config.js; file missing or incorrect.","error":"Error: Cannot find module './env.js'"},{"fix":"Use default import: import variables from 'rollup-plugin-variables'.","cause":"Using named import { variables } instead of default import.","error":"TypeError: variables is not a function"},{"fix":"Use supported marker format: '[[]]', '{{}}', or another string with matching brackets.","cause":"Marker option string or function must return a valid format like '[[]]' or '{{}}'.","error":"The marker format 'invalid' is not supported."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}