Registry / devops / rollup-plugin-htaccess

rollup-plugin-htaccess

JSON →
library0.13.1jsnpmunverified

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.

npm install rollup-plugin-htaccess
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-HTAC
R
rollup-plugin-htaccess
devopsjavascriptv0.13.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

htaccess
import htaccess from 'rollup-plugin-htaccess'
const htaccess = require('rollup-plugin-htaccess')
Default export is the plugin function. Use ESM import or dynamic import() for CJS projects.
HTAccessOptions
import { HTAccessOptions } from 'rollup-plugin-htaccess'
const { HTAccessOptions } = require('rollup-plugin-htaccess')
TypeScript type for plugin options, exported as named type. Not available in CJS require.
DirectiveSet
import { DirectiveSet } from 'rollup-plugin-htaccess'
TypeScript type for available directive keys. Exported for type checking.

Example Rollup configuration using htaccess plugin to generate .htaccess with redirects, security, and caching rules.

import htaccess from 'rollup-plugin-htaccess'; export default { input: 'src/index.js', output: { dir: 'dist', format: 'es' }, plugins: [ htaccess({ redirects: [ { from: '/old-path', to: '/new-path', type: 301 }, { from: '/temporary', to: '/elsewhere', type: 302 } ], security: { disableDirectoryBrowsing: true, blockAccessToHiddenFiles: true }, performance: { enableCompression: true, setExpires: { 'image/png': '1 month', 'text/css': '1 week' } } }) ] };
Debug
Known issues
breakingPlugin requires Node >= 20; older Node versions will fail to run.
fix
Upgrade Node.js to version 20 or higher.
affects: >=0.13.0
breakingBreaking change in v0.13: option `enableHTTPS` renamed to `forceHTTPS`.
fix
Replace `enableHTTPS: true` with `forceHTTPS: true` in your plugin config.
affects: >=0.13.0
deprecatedThe `cache` option is deprecated and will be removed in v1.0.
fix
Use the `performance` object with `setExpires` and `setCacheControl` instead.
affects: >=0.12.0
gotchaPlugin is ESM-only; require() will not work without using dynamic import.
fix
Use `import htaccess from 'rollup-plugin-htaccess'` or `const htaccess = (await import('rollup-plugin-htaccess')).default`.
affects: >=0.13.0
gotchaWhen using with Vite, the plugin must be placed in the `plugins` array of your vitest config, not in the vite config itself.
fix
Add plugin to `plugins` in the `test` section of your vitest config.
affects: >=0.11.0
Errors
Common errors & fixes
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.
Using CommonJS require() to load an ESM-only package.
fix
Change your rollup config to use ESM (`.mjs` extension or `"type": "module"` in package.json) and use `import htaccess from 'rollup-plugin-htaccess'`.
TypeError: htaccess is not a function
Importing the plugin incorrectly (e.g., using named import instead of default).
fix
Use default import: `import htaccess from 'rollup-plugin-htaccess'`.
Error: Cannot find module 'rollup-plugin-htaccess'
Plugin not installed or missing from devDependencies.
fix
Run `npm install --save-dev rollup-plugin-htaccess` to install the package.
Upgrade
Version history
0.13.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Resources
rollup-plugin-htaccess — npm install rollup-plugin-htaccess · libregistry