vite-plugin-resolve
Advanced tools
Comparing version 2.0.2 to 2.0.3
{ | ||
"name": "vite-plugin-resolve", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "Custom resolve module content.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -18,24 +18,23 @@ # vite-plugin-resolve [![NPM version](https://img.shields.io/npm/v/vite-plugin-resolve.svg)](https://npmjs.org/package/vite-plugin-resolve) [![awesome-vite](https://awesome.re/badge.svg)](https://github.com/vitejs/awesome-vite) | ||
Resolve custom module content, this like Vite external plugin | ||
```ts | ||
import { defineConfig } from 'vite' | ||
import resolve from 'vite-plugin-resolve' | ||
export default defineConfig({ | ||
export default { | ||
plugins: [ | ||
resolve({ | ||
// Resolve custom module content | ||
// This like Vite external plugin | ||
vue: `const vue = window.Vue; export { vue as default }`, | ||
}), | ||
] | ||
}) | ||
} | ||
``` | ||
#### Load a local file | ||
#### Load a file | ||
Support nested module id, support return Promise | ||
```ts | ||
resolve({ | ||
// Support nested module id | ||
// Support return Promise | ||
'@scope/name': () => require('fs/promises').readFile('path', 'utf-8'), | ||
'path/filename': () => require('fs/promises').readFile('path', 'utf-8'), | ||
}) | ||
@@ -46,5 +45,6 @@ ``` | ||
Resolve Electron `ipcRenderer` in Renderer-process | ||
```ts | ||
resolve({ | ||
// Resolve Electron ipcRenderer in Renderer-process | ||
electron: `const { ipcRenderer } = require('electron'); export { ipcRenderer };`, | ||
@@ -51,0 +51,0 @@ }) |
@@ -18,24 +18,23 @@ # vite-plugin-resolve [![NPM version](https://img.shields.io/npm/v/vite-plugin-resolve.svg)](https://npmjs.org/package/vite-plugin-resolve) [![awesome-vite](https://awesome.re/badge.svg)](https://github.com/vitejs/awesome-vite) | ||
加载自定模块内容,这个场景就是 external | ||
```ts | ||
import { defineConfig } from 'vite' | ||
import resolve from 'vite-plugin-resolve' | ||
export default defineConfig({ | ||
export default { | ||
plugins: [ | ||
resolve({ | ||
// 加载自定模块内容 | ||
// 这个场景就是 external | ||
vue: `const vue = window.Vue; export { vue as default }`, | ||
}), | ||
] | ||
}) | ||
} | ||
``` | ||
#### 读取本地文件 | ||
#### 加载文件 | ||
支持嵌套模块命名,支持返回 Promise | ||
```ts | ||
resolve({ | ||
// 支持嵌套模块命名 | ||
// 支持返回 Promise | ||
'@scope/name': async () => await require('fs/promises').readFile('path', 'utf-8'), | ||
'path/filename': () => require('fs/promises').readFile('path', 'utf-8'), | ||
}) | ||
@@ -46,5 +45,6 @@ ``` | ||
在 Electron 渲染进程中加载 `ipcRenderer` | ||
```ts | ||
resolve({ | ||
// 在 Electron 渲染进程中加载 ipcRenderer | ||
electron: `const { ipcRenderer } = require('electron'); export { ipcRenderer };`, | ||
@@ -51,0 +51,0 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
5679