Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
vite-plugin-resolve
Advanced tools
Custom resolve module content
English | 简体中文
npm i -D vite-plugin-resolve
import { defineConfig } from 'vite'
import viteResolve from 'vite-plugin-resolve'
export default defineConfig({
plugins: [
viteResolve({
// resolve external module, this like Vite external plugin
vue: `const vue = window.Vue; export { vue as default }`,
// nested moduleId and return Promis<string>
'@scope/name': async () => await require('fs').promises.readFile('path', 'utf-8'),
// electron
electron: `const { ipcRenderer } = require('electron'); export { ipcRenderer };`,
})
]
})
export type viteResolve = (
resolves: [moduleId: string]: string | (() => string | Promise<string>),
options?: {
/**
* @default true
* Whether to insert the resolve module into "optimizeDeps.exclude"
*/
optimize: boolean
}
) => import('vite').VitePlugin
Let's use Vue as an example
viteResolve({
vue: `const vue = window.Vue; export { vue as default }`,
})
node_modules/.vite-plugin-resolve/vue.js
and contains the following codeconst vue = window.Vue; export { vue as default }
vue
alias item and add it to resolve.alias
{
resolve: {
alias: [
{
find: 'vue',
replacement: 'User/work-directory/node_modules/.vite-plugin-resolve/vue.js',
},
],
},
}
vue
to the optimizeDeps.exclude
by default. You can disable it through options.optimize
export default {
optimizeDeps: {
exclude: ['vue'],
},
}
FAQs
Custom resolve module content.
The npm package vite-plugin-resolve receives a total of 3,034 weekly downloads. As such, vite-plugin-resolve popularity was classified as popular.
We found that vite-plugin-resolve demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 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
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.