Registry / devops / vite-plugin-robots

vite-plugin-robots

JSON →
library1.0.5jsnpmunverified

Vite plugin for generating robots.txt files with separate configurations for production and development builds. Current stable version is 1.0.5, released with a consistent cadence. Key differentiator: it allows you to define different robots.txt rules based on build mode by reading `.robots.[mode].txt` or `.robots.[mode].txt.local` files from the project root, making it easy to block crawlers in development and allow them in production without manual file swapping.

npm install vite-plugin-robots
INSTALL
IMPORT
SIG · VITE-PLUGIN-ROBOTS
V
vite-plugin-robots
devopsjavascriptv1.0.5
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.

robots
import { robots } from 'vite-plugin-robots'
import robots from 'vite-plugin-robots'
The package exports a named export, not a default export. Common mistake is using default import.
type Plugin
import type { Plugin } from 'vite'
Type import is used when TypeScript is enabled; no wrong pattern commonly reported.
defineConfig
import { defineConfig } from 'vite'
Standard Vite pattern; no common mistake.

Shows how to install, import, and configure the plugin with example robots.txt files for production and development.

import { robots } from 'vite-plugin-robots' import { defineConfig } from 'vite' export default defineConfig({ plugins: [ robots({ // Optional: override default file names or disable }) ] }) // Create .robots.production.txt in project root: // User-agent: * // Allow: / // Sitemap: https://example.com/sitemap.xml // Create .robots.development.txt in project root: // User-agent: * // Disallow: /
Debug
Known issues
gotchaPlugin only reads files named `.robots.[mode].txt` or `.robots.[mode].txt.local` from project root; custom paths not supported.
fix
Place your robots.txt files in the project root with the correct naming convention.
affects: >=1.0.0
deprecatedAs of v1.0.0, the option `skip` has been removed; use a falsy config to disable the plugin.
fix
Remove `skip` property from config; instead omit the plugin or set `false` conditionally.
affects: >=1.0.0
breakingFrom v0.x to v1.0.0, the import changed from default to named export.
fix
Change `import robots from 'vite-plugin-robots'` to `import { robots } from 'vite-plugin-robots'`.
affects: <1.0.0
gotchaPlugin does not merge multiple robots.txt files; it only outputs one per build mode.
fix
Ensure you have only one set of `.robots.*.txt` files or combine rules manually.
affects: >=1.0.0
Errors
Common errors & fixes
SyntaxError: Unexpected token '.'
Using CommonJS `require` to import ESM-only package (Vite plugins are ESM).
fix
Use `import { robots } from 'vite-plugin-robots'` instead of `const { robots } = require('vite-plugin-robots')`.
Error: robots is not a function
Default import instead of named import.
fix
Change to `import { robots } from 'vite-plugin-robots'`.
Error: The plugin 'robots' does not provide a valid function
Passing an object instead of calling the function in plugins array.
fix
Use `robots({...})` in the plugins array, not just `robots`.
Upgrade
Version history
1.0.5latest on npm
Audit
Dependencies
viterequiredPeer dependency; the plugin requires Vite >=3 as a build tool.
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
vite-plugin-robots — npm install vite-plugin-robots · libregistry