npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

vite-plugin-robots-ts

v2.1.1

Published

Vite plugin to generate robots.txt. Supports AI blocking and works in dev mode.

Downloads

751

Readme

vite-plugin-robots-ts

A Vite plugin to generate robots.txt. Supports blocking AI training crawlers and works in development mode by proxying middleware to /robots.txt.

Installation

npm install -D vite-plugin-robots-ts
pnpm add -D vite-plugin-robots-ts
yarn add -D vite-plugin-robots-ts
bun add -D vite-plugin-robots-ts
deno add -D npm:vite-plugin-robots-ts

Usage

// vite.config.ts
import { robots } from 'vite-plugin-robots-ts'

export default {
  plugins: [
    robots(), // block all robots by default
  ],
}

Examples

Block all (default):

robots()

// or

import { BLOCK_ALL, robots } from 'vite-plugin-robots-ts'

robots({ content: BLOCK_ALL })

Output:

User-agent: *
Disallow: /

Allow all:

import { ALLOW_ALL, robots } from 'vite-plugin-robots-ts'

robots({ content: ALLOW_ALL })

Output:

User-agent: *
Disallow:

Block only AI training crawlers (allow rest):

import { BLOCK_AI_ALLOW_REST, robots } from 'vite-plugin-robots-ts'

robots({ content: BLOCK_AI_ALLOW_REST })

Output:

User-agent: Amazonbot
Disallow: /

User-agent: Applebot-Extended
Disallow: /

User-agent: Bytespider
Disallow: /

User-agent: CCBot
Disallow: /

User-agent: ClaudeBot
Disallow: /

User-agent: Google-Extended
Disallow: /

User-agent: GPTBot
Disallow: /

User-agent: meta-externalagent
Disallow: /

User-agent: *
Disallow:

Use built-in presets:

import { BLOCK_AI, BLOCK_ALL, robots } from 'vite-plugin-robots-ts'

robots({
  content:
    process.env.NODE_ENV === 'production'
      ? `${BLOCK_AI}\n<Custom content here>`
      : BLOCK_ALL,
})

Output (production):

User-agent: Amazonbot
Disallow: /

User-agent: Applebot-Extended
Disallow: /

User-agent: Bytespider
Disallow: /

User-agent: CCBot
Disallow: /

User-agent: ClaudeBot
Disallow: /

User-agent: Google-Extended
Disallow: /

User-agent: GPTBot
Disallow: /

User-agent: meta-externalagent
Disallow: /

<Custom content here>

Output (all other environments):

User-agent: *
Disallow: /

Use custom content:

robots({
  content: `User-agent: *
Disallow: /admin
Disallow: /secret`,
})

Output:

User-agent: *
Disallow: /admin
Disallow: /secret

Append sitemap directive:

import { ALLOW_ALL, robots } from 'vite-plugin-robots-ts'

robots({
  content: ALLOW_ALL,
  sitemap: 'https://example.com/sitemap.xml'
})

Output:

User-agent: *
Disallow:

Sitemap: https://example.com/sitemap.xml

Multiple sitemaps:

import { ALLOW_ALL, robots } from 'vite-plugin-robots-ts'

robots({
  content: ALLOW_ALL,
  sitemap: [
    'https://example.com/sitemap.xml',
    'https://example.com/sitemap-news.xml',
  ]
})

Output:

User-agent: *
Disallow:

Sitemap: https://example.com/sitemap.xml
Sitemap: https://example.com/sitemap-news.xml

Options

All options are optional.

| Option | Type | Default | Description | |---------|----------------------|-------------|------------------------------------------------------------------------------| | content | string | BLOCK_ALL | Custom content for robots.txt | | sitemap | string | string[] | - | Adds Sitemap directive(s) to robots.txt | | outDir | string | - | Custom output directory for robots.txt (resolved relative to project root) |

Constants

The plugin exports preset constants that can be used with the content option or composed into custom configurations:

| Constant | Description | |-----------------------|---------------------------------------------------------------| | ALLOW_ALL | Allows all robots (User-agent: * / Disallow:) | | BLOCK_ALL | Blocks all robots (User-agent: * / Disallow: /) | | BLOCK_AI | Blocks known AI training crawlers only | | BLOCK_AI_ALLOW_REST | Blocks known AI training crawlers and allows all other robots |

Usage

import {
  ALLOW_ALL,
  BLOCK_ALL,
  BLOCK_AI,
  BLOCK_AI_ALLOW_REST,
} from 'vite-plugin-robots-ts'