
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
@originjs/vite-plugin-require-context
Advanced tools
A vite plugin that support require.context in vite
Support require.context
in vite
.
snyc
/eager
mode is supported for now./^.*$/
, and it's different from webpack's default regexp /^\.\/.*$/
.require.context.id
is different from webpack.require.context("./dir_name/", true, /\.vue$/)
, require.context("../dir_name/", false, /\.vue$/)
node_modules
: require.context("dir_name", true, /\.vue$/)
src
: require.context("@/dir_name/", true, /\.vue$/)
npm install @originjs/vite-plugin-require-context --save-dev
or
yarn add @originjs/vite-plugin-require-context --dev
import ViteRequireContext from '@originjs/vite-plugin-require-context'
export default {
plugins: [
ViteRequireContext(
/* options */
)
]
}
projectBasePath: string
The base path of your project used in require.context. Default to be process.cwd()
defaultRegExp: RegExp
The default RegExp used in require.context
if the third parameter regExp
of require.context
is not specified. Default to be /^.*$/
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
FAQs
A vite plugin that support require.context in vite
The npm package @originjs/vite-plugin-require-context receives a total of 5,437 weekly downloads. As such, @originjs/vite-plugin-require-context popularity was classified as popular.
We found that @originjs/vite-plugin-require-context demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.