{"id":22816,"library":"vite-plugin-robots","title":"vite-plugin-robots","description":"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.","status":"active","version":"1.0.5","language":"javascript","source_language":"en","source_url":"https://github.com/kolirt/vite-plugin-robots","tags":["javascript","vite","vite-plugin","robots","robots.txt","vue","react","angular","typescript"],"install":[{"cmd":"npm install vite-plugin-robots","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-robots","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-robots","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; the plugin requires Vite >=3 as a build tool.","package":"vite","optional":false}],"imports":[{"note":"The package exports a named export, not a default export. Common mistake is using default import.","wrong":"import robots from 'vite-plugin-robots'","symbol":"robots","correct":"import { robots } from 'vite-plugin-robots'"},{"note":"Type import is used when TypeScript is enabled; no wrong pattern commonly reported.","wrong":"","symbol":"type Plugin","correct":"import type { Plugin } from 'vite'"},{"note":"Standard Vite pattern; no common mistake.","wrong":"","symbol":"defineConfig","correct":"import { defineConfig } from 'vite'"}],"quickstart":{"code":"import { robots } from 'vite-plugin-robots'\nimport { defineConfig } from 'vite'\n\nexport default defineConfig({\n  plugins: [\n    robots({\n      // Optional: override default file names or disable\n    })\n  ]\n})\n\n// Create .robots.production.txt in project root:\n// User-agent: *\n// Allow: /\n// Sitemap: https://example.com/sitemap.xml\n\n// Create .robots.development.txt in project root:\n// User-agent: *\n// Disallow: /","lang":"typescript","description":"Shows how to install, import, and configure the plugin with example robots.txt files for production and development."},"warnings":[{"fix":"Place your robots.txt files in the project root with the correct naming convention.","message":"Plugin only reads files named `.robots.[mode].txt` or `.robots.[mode].txt.local` from project root; custom paths not supported.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Remove `skip` property from config; instead omit the plugin or set `false` conditionally.","message":"As of v1.0.0, the option `skip` has been removed; use a falsy config to disable the plugin.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Change `import robots from 'vite-plugin-robots'` to `import { robots } from 'vite-plugin-robots'`.","message":"From v0.x to v1.0.0, the import changed from default to named export.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Ensure you have only one set of `.robots.*.txt` files or combine rules manually.","message":"Plugin does not merge multiple robots.txt files; it only outputs one per build mode.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use `import { robots } from 'vite-plugin-robots'` instead of `const { robots } = require('vite-plugin-robots')`.","cause":"Using CommonJS `require` to import ESM-only package (Vite plugins are ESM).","error":"SyntaxError: Unexpected token '.'"},{"fix":"Change to `import { robots } from 'vite-plugin-robots'`.","cause":"Default import instead of named import.","error":"Error: robots is not a function"},{"fix":"Use `robots({...})` in the plugins array, not just `robots`.","cause":"Passing an object instead of calling the function in plugins array.","error":"Error: The plugin 'robots' does not provide a valid function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}