{"id":22055,"library":"rollup-plugin-htaccess","title":"rollup-plugin-htaccess","description":"A Rollup/Rolldown/Vite plugin that generates .htaccess files during the build process. Current stable version is 0.13.1. Supports Apache directives with type-safe configuration via TypeScript types. The plugin integrates with Rollup (v3.29.4+), Rolldown (v1.0.0-rc7+), and Vite (v4.5.14+). Key differentiators: no runtime dependencies, comprehensive directive support, and native ESM/CJS compatibility. Requires Node >= 20. Released on npm with monthly updates.","status":"active","version":"0.13.1","language":"javascript","source_language":"en","source_url":"https://github.com/marekdedic/rollup-plugin-htaccess","tags":["javascript","rollup-plugin","htaccess","apache","typescript"],"install":[{"cmd":"npm install rollup-plugin-htaccess","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-htaccess","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-htaccess","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export is the plugin function. Use ESM import or dynamic import() for CJS projects.","wrong":"const htaccess = require('rollup-plugin-htaccess')","symbol":"htaccess","correct":"import htaccess from 'rollup-plugin-htaccess'"},{"note":"TypeScript type for plugin options, exported as named type. Not available in CJS require.","wrong":"const { HTAccessOptions } = require('rollup-plugin-htaccess')","symbol":"HTAccessOptions","correct":"import { HTAccessOptions } from 'rollup-plugin-htaccess'"},{"note":"TypeScript type for available directive keys. Exported for type checking.","wrong":null,"symbol":"DirectiveSet","correct":"import { DirectiveSet } from 'rollup-plugin-htaccess'"}],"quickstart":{"code":"import htaccess from 'rollup-plugin-htaccess';\n\nexport default {\n  input: 'src/index.js',\n  output: { dir: 'dist', format: 'es' },\n  plugins: [\n    htaccess({\n      redirects: [\n        { from: '/old-path', to: '/new-path', type: 301 },\n        { from: '/temporary', to: '/elsewhere', type: 302 }\n      ],\n      security: {\n        disableDirectoryBrowsing: true,\n        blockAccessToHiddenFiles: true\n      },\n      performance: {\n        enableCompression: true,\n        setExpires: { 'image/png': '1 month', 'text/css': '1 week' }\n      }\n    })\n  ]\n};","lang":"typescript","description":"Example Rollup configuration using htaccess plugin to generate .htaccess with redirects, security, and caching rules."},"warnings":[{"fix":"Upgrade Node.js to version 20 or higher.","message":"Plugin requires Node >= 20; older Node versions will fail to run.","severity":"breaking","affected_versions":">=0.13.0"},{"fix":"Replace `enableHTTPS: true` with `forceHTTPS: true` in your plugin config.","message":"Breaking change in v0.13: option `enableHTTPS` renamed to `forceHTTPS`.","severity":"breaking","affected_versions":">=0.13.0"},{"fix":"Use the `performance` object with `setExpires` and `setCacheControl` instead.","message":"The `cache` option is deprecated and will be removed in v1.0.","severity":"deprecated","affected_versions":">=0.12.0"},{"fix":"Use `import htaccess from 'rollup-plugin-htaccess'` or `const htaccess = (await import('rollup-plugin-htaccess')).default`.","message":"Plugin is ESM-only; require() will not work without using dynamic import.","severity":"gotcha","affected_versions":">=0.13.0"},{"fix":"Add plugin to `plugins` in the `test` section of your vitest config.","message":"When using with Vite, the plugin must be placed in the `plugins` array of your vitest config, not in the vite config itself.","severity":"gotcha","affected_versions":">=0.11.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Change your rollup config to use ESM (`.mjs` extension or `\"type\": \"module\"` in package.json) and use `import htaccess from 'rollup-plugin-htaccess'`.","cause":"Using CommonJS require() to load an ESM-only package.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/rollup-plugin-htaccess/dist/index.js from /path/to/project/rollup.config.js not supported."},{"fix":"Use default import: `import htaccess from 'rollup-plugin-htaccess'`.","cause":"Importing the plugin incorrectly (e.g., using named import instead of default).","error":"TypeError: htaccess is not a function"},{"fix":"Run `npm install --save-dev rollup-plugin-htaccess` to install the package.","cause":"Plugin not installed or missing from devDependencies.","error":"Error: Cannot find module 'rollup-plugin-htaccess'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}