@originjs/vite-plugin-require-context weekly downloads statistics
By originjs (2 listings) · npm · Vite plugins
A vite plugin that support require.context in vite
@originjs/vite-plugin-require-context has 8,669 recorded weekly downloads on npm, an increase of 10.4% over the past 30 days, ranking #1332 of 3,247 tracked listings.
About @originjs/vite-plugin-require-context
vite-plugin-require-context
Support require.context in vite.
Features
- Based on RegExp search and replacement.
- Only
snyc/eagermode is supported for now. - The default regexp is
/^.*$/, and it's different from webpack's default regexp/^\.\/.*$/. - The implementation of
require.context.idis different from webpack. - Syntax supported :
- search in relative path :
require.context("./dir_name/", true, /\.vue$/),require.context("../dir_name/", false, /\.vue$/) - search in
node_modules:require.context("dir_name", true, /\.vue$/) - search in
src:require.context("@/dir_name/", true, /\.vue$/)
- search in relative path :
Install
npm install @originjs/vite-plugin-require-context --save-dev
or
yarn add @originjs/vite-plugin-require-context --dev
Usage
import ViteRequireContext from '@originjs/vite-plugin-require-context'
export default {
plugins: [
ViteRequireContext(
/* options */
)
]
}
Options
-
projectBasePath: stringThe base path of your project used in require.context. Default to beprocess.cwd() -
defaultRegExp: RegExpThe default RegExp used inrequire.contextif the third parameterregExpofrequire.contextis not specified. Default to be/^.*$/
Implementation details
The following require.context
const requireComponents = require.context('./components')
will be replaced by
// generated by @originjs/vite-plugin-require-context
// start of generated code of __require_context_for_vite_function_0, generated by @originjs/vite-plugin-require-context
import * as __require_context_for_vite_0_0 from "/src/components/a.vue";
import * as __require_context_for_vite_0_1 from "/src/components/b.vue";
import * as __require_context_for_vite_0_2 from "/src/components/c.vue";
var __require_context_for_vite_map_0 = {
"./a.vue" : __require_context_for_vite_0_0,
"./b.vue" : __require_context_for_vite_0_1,
"./c.vue" : __require_context_for_vite_0_2
};
function __require_context_for_vite_function_0(req) {
var id = __require_context_for_vite_function_0_resolve(req);
return __require_context_for_vite_map_0[req];
}
function __require_context_for_vite_function_0_resolve(req) {
if (req in __require_context_for_vite_map_0) {
return __require_context_for_vite_map_0[req];
}
var e = new Error("Cannot find module '" + req + "'");
e.code = 'MODULE_NOT_FOUND';
throw e;
}
__require_context_for_vite_function_0.keys = function __require_context_for_vite_function_0_keys() {
return Object.keys(__require_context_for_vite_map_0);
}
__require_context_for_vite_function_0.resolve = __require_context_for_vite_function_0_resolve
__require_context_for_vite_function_0.id = "__require_context_for_vite_function_0"
// end of generated code of __require_context_for_vite_function_0
const requireComponents = __require_context_for_vite_function_0
Description from the npm listing.
- vite-plugin
- require.context
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
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.
Each band is one page of 20. Weekly downloads on a linear 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.
Recent observations
Full history (170)Similar npm Vite plugins plugins
All 20 @originjs/vite-plugin-require-context alternativesData 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/@originjs/vite-plugin-require-context. First seen Oct 16, 2026; last successful collection Dec 5, 2026. See the methodology.