
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
vite-plugin-resolve
Advanced tools
Custom resolve module content
English | įŽäŊ䏿
npm i vite-plugin-resolve -D
You can load any code snippets you want (ESM format)
import resolve from 'vite-plugin-resolve'
export default {
plugins: [
resolve({
// Browser
vue: `
const vue = window.Vue;
const version = vue.version;
export {
vue as default,
version,
}
`,
// Node.js, Electron
electron: `
const { ipcRenderer, shell } = require('electron');
export {
ipcRenderer,
shell,
}
`,
}),
]
}
// Use in your app
import Vue, { version } from 'vue'
import { ipcRenderer, shell } from 'electron'
// Make sure that index.html has introduced the CDN file.
// e.g.
// <script src="https://unpkg.com/vue@3.2.45/dist/vue.global.js"></script>
Use with lib-esm
npm i lib-esm
import resolve from 'vite-plugin-resolve'
import libEsm from 'lib-esm'
export default {
plugins: [
resolve({
// Let's use lodash as an example
lodash: () => {
const snippets = libEsm({
// lodash iife name
window: '_',
// export memebers
exports: [
'chunk',
'curry',
'debounce',
'throttle',
],
})
return `${snippets.window}\n${snippets.exports}`
},
}),
],
}
// Use in your app
import _, { chunk, curry, debounce, throttle } from 'lodash'
Use in Electron đ electron-vite-vue
This like Vite external plugin
import resolve from 'vite-plugin-resolve'
import {
ant_design_vue,
antd,
axios,
element_plus,
element_ui,
pinia,
react_dom,
react_router_dom,
react_router,
react,
redux,
vue_composition_api,
vue_demi,
vue_router,
vue,
vuex,
} from 'vite-plugin-resolve/presets'
export default {
plugins: [
resolve({
// e.g.
// external-lib: lib-name.version
vue: vue.v3,
react: react.v18,
}),
]
}
// Use in your app
import Vue, { ref, reactive, computed, watch } from 'vue'
import React, { useState, useEffect } from 'react'
resolve(entries)
function resolve(entries: {
[moduleId: string]:
| import('rollup').LoadResult
| import('vite').Plugin['load'];
}): import('vite').Plugin[];
You can see the return value type definition here rollup/types.d.ts#L272
There are two main differences
vite:resolve
pluginFAQs
Custom resolve module content.
The npm package vite-plugin-resolve receives a total of 4,287 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
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600Ã faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.