Skip to content
PluginStats

unplugin-preprocessor-directives weekly downloads statistics

By kejunmao (2 listings) · npm · Vite plugins

<img src="assets/logo.svg" alt="logo" width="100" height="100" align="right" />

View on npm Fresh · Oct 17, 2026

unplugin-preprocessor-directives has 2,657 recorded weekly downloads on npm, a decrease of 66.8% over the past 30 days.

It ranks #1225 of 2,251 tracked npm listings by weekly downloads.

Over 90 days, weekly downloads changed by -40.2%.

PluginStats has 121 daily observations since Jun 19, 2026; the latest is from Oct 17, 2026.

Weekly downloads
2,657
Official API · Oct 17, 2026
7-day growth
-43.2%
-2K weekly downloads
30-day growth
-66.8%
-5.3K weekly downloads
90-day growth
-40.2%
-1.8K weekly downloads
Rank
#1225
Among tracked npm listings

About unplugin-preprocessor-directives

unplugin-preprocessor-directives

[![npm version][npm-version-src]][npm-version-href] [![npm downloads][npm-downloads-src]][npm-downloads-href] [![github stars][github-stars-src]][github-stars-href] [![bundle][bundle-src]][bundle-href] [![License][license-src]][license-href] [![JSDocs][jsdocs-src]][jsdocs-href]

English | 简体中文

Install

[!NOTE] This plugin should be placed before all other plugins in your configuration to ensure preprocessor directives are processed first.

Vite

Example: playground/

Rollup

Webpack

Nuxt

This module works for both Nuxt 2 and Nuxt Vite

Vue CLI

esbuild

Rspack (⚠️ experimental)

Usage

Defining symbols

You use the following two preprocessor directives to define or undefine symbols for conditional compilation:

• #define: Define a symbol. • #undef: Undefine a symbol.

You use #define to define a symbol. When you use the symbol as the expression that's passed to the #if directive, the expression will evaluate to true, as the following example shows:

Conditional compilation

• #if: Opens a conditional compilation, where code is compiled only if the specified symbol is defined and evaluated to true. • #elif: Closes the preceding conditional compilation and opens a new conditional compilation based on if the specified symbol is defined and evaluated to true. • #else: Closes the preceding conditional compilation and opens a new conditional compilation if the previous specified symbol isn't defined or evaluated to false. • #endif: Closes the preceding conditional compilation.

[!NOTE] By default, use vite's loadEnv function to load environment variables based on process.env.NODE_ENV and compile symbols as conditions.

You can use the operators == (equality) and != (inequality) to test for the bool values true or false. true means the symbol is defined. The statement #if DEBUG has the same meaning as #if (DEBUG == true). You can use the && (and), || (or), and ! (not) operators to evaluate whether multiple symbols have been defined. You can also group symbols and operators with parentheses.

Error and warning and info messages

You instruct the compiler to generate user-defined compiler errors and warnings and informational messages.

• #error: Generates an error, but does not terminate compilation. • #warning: Generates a warning. • #info: Generates an informational message.

Of course, it can also be combined with conditional compilation:

#include directive

You can use the #include directive to include the contents of other files into the current file. The included files are also processed by the preprocessor.

[!WARNING] The #include directive is a compile-time text replacement tool, primarily intended for these scenarios: - Including different configuration code snippets in different environments - Combining with conditional compilation to include different code based on compilation conditions - Sharing code snippets that require preprocessing

It cannot and should not replace: - JavaScript/TypeScript import or require - for modularization and dependency management - CSS @import - for stylesheet modularization - HTML template systems or component systems

If you simply want to modularize your code, please use the language's native module system. Only use #include when you need compile-time processing and conditional inclusion.

this directive supports the following two syntaxes:

[!NOTE] 1. Circular references: If file A includes file B, and file B includes file A, circular references will be automatically detected and prevented, processing only once 2. Path resolution: Relative paths are resolved relative to the configured working directory (cwd) 3. File extensions: Any type of text file can be included, not limited to .js files 4. Nested processing: Included files are fully processed by the preprocessor, so all supported directives can be used

Custom directive

You can used defineDirective to define your own directive.

Taking the built-in directive as an example:

enforce: 'pre' | 'post'

Execution priority of directives

• pre: Execute as early as possible • post: Execute as late as possible

Description from the npm listing.

  • unplugin
  • vite
  • webpack
  • rollup
  • rspack
  • transform
  • vite-plugin
  • webpack-plugin
  • rollup-plugin
  • esbuild-plugin
  • rspack-plugin
  • nuxt-plugin
  • directives
  • preprocessor

Where unplugin-preprocessor-directives sits in the listing

Each band is one page of 20. Weekly downloads on a log scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.

All npm2,248 listings · 113 pages · page 62, #5 (overall #1225)
All npm: every listing in weekly downloads order
PNG SVG
Vite plugins250 listings · 13 pages · page 12, #17 (overall #237)
Vite plugins: every listing in weekly downloads order
PNG SVG

Charts

Images: 30d · 1y · all time · 1600×900 dark

Adoption over time

unplugin-preprocessor-directives weekly downloads on npm, last 90 days: 2,657 weekly downloads as of Oct 17, 2026, -40.2% over 90 days.unplugin-preprocessor-directivesWeekly downloads on npm · Last 90 days2,657downloads / week-40.2% over 90 days02K4K6K8K10KJul 19Aug 3Aug 18Sep 2Sep 17Oct 2Oct 17downloads / weekobservedarchived (Internet Archive)no observationsJul 20, 2026 – Oct 17, 2026 · 90 observations · Updated Oc…pluginstats.com
unplugin-preprocessor-directives weekly downloads on npm, last 90 days: 2,657 weekly downloads as of Oct 17, 2026, -40.2% over 90 days.
PNG SVG

7/30/90-day growth

unplugin-preprocessor-directives weekly downloads growth on npm: -43.2% over 7 days, -66.8% over 30 days, -40.2% over 90 days.unplugin-preprocessor-directivesWeekly downloads growth on npm2,657downloads / week now7-day growth-2,019 weekly downloads-43.2%30-day growth-5,335 weekly downloads-66.8%90-day growth-1,784 weekly downloads-40.2%Growth vs. nearest observation to each baseline date · Updated Oct 17, 2026pluginstats.com
unplugin-preprocessor-directives weekly downloads growth on npm: -43.2% over 7 days, -66.8% over 30 days, -40.2% over 90 days.
PNG SVG

Ranking history

unplugin-preprocessor-directives npm ranking history: currently #1225 (by weekly downloads).unplugin-preprocessor-directivesnpm ranking · by weekly downloads · Last 90 days#1225current rank#1223#1224#1225#1226#1227Jul 20Aug 4Aug 19Sep 3Sep 18Oct 3Oct 18rankOct 18, 2026 – Oct 18, 2026 · 1 observations · Updated Oct 17, 2026pluginstats.com
unplugin-preprocessor-directives npm ranking history: currently #1225 (by weekly downloads).
PNG SVG

Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.

Recent observations

Full history (121)
Recent weekly downloads observations for unplugin-preprocessor-directives
Date (UTC)Weekly downloadsChange vs. previous
2,657-338
2,995+373
2,622-993
3,615-1K
4,6420
4,642-70
4,712+36
4,676-23
4,699+213
4,486-396
4,882-17
4,899-986
5,885+43
5,842—

Similar npm Vite plugins plugins

Data source

Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.

Listing: https://www.npmjs.com/package/unplugin-preprocessor-directives. First seen Oct 16, 2026; last successful collection Oct 18, 2026. See the methodology.