use vite-plugin-optimizer instead vite-plugin-resolve

This commit is contained in:
草鞋没号 2022-03-23 19:49:37 +08:00
parent 6c48b270e2
commit 896db3ea08
3 changed files with 14 additions and 14 deletions

18
package-lock.json generated
View File

@ -17,7 +17,7 @@
"simple-git-hooks": "^2.7.0",
"typescript": "^4.5.5",
"vite": "^2.7.13",
"vite-plugin-resolve": "^1.8.0",
"vite-plugin-optimizer": "^1.1.4",
"vue": "^3.2.29",
"vue-tsc": "^0.31.1"
},
@ -6105,10 +6105,10 @@
}
}
},
"node_modules/vite-plugin-resolve": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/vite-plugin-resolve/-/vite-plugin-resolve-1.8.0.tgz",
"integrity": "sha512-zWj2tsi3GpYbF+RdUi8Bad1MsnOefak4G93yNntlWrHKuxZniGGySMtimp/6Qc5e/DjO8LLstJm7EkdjsZqxjQ==",
"node_modules/vite-plugin-optimizer": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/vite-plugin-optimizer/-/vite-plugin-optimizer-1.1.4.tgz",
"integrity": "sha512-oExg8rJhgALOl6LEg0DYXs8KQSKwLy9JswqtnpKD2RvjwW774O/e9F6EyspdsHRpTDNPvduV1DvHpv4p/DdxRQ==",
"dev": true
},
"node_modules/void-elements": {
@ -11173,10 +11173,10 @@
"rollup": "^2.59.0"
}
},
"vite-plugin-resolve": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/vite-plugin-resolve/-/vite-plugin-resolve-1.8.0.tgz",
"integrity": "sha512-zWj2tsi3GpYbF+RdUi8Bad1MsnOefak4G93yNntlWrHKuxZniGGySMtimp/6Qc5e/DjO8LLstJm7EkdjsZqxjQ==",
"vite-plugin-optimizer": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/vite-plugin-optimizer/-/vite-plugin-optimizer-1.1.4.tgz",
"integrity": "sha512-oExg8rJhgALOl6LEg0DYXs8KQSKwLy9JswqtnpKD2RvjwW774O/e9F6EyspdsHRpTDNPvduV1DvHpv4p/DdxRQ==",
"dev": true
},
"void-elements": {

View File

@ -24,7 +24,7 @@
"simple-git-hooks": "^2.7.0",
"typescript": "^4.5.5",
"vite": "^2.7.13",
"vite-plugin-resolve": "^1.8.0",
"vite-plugin-optimizer": "^1.1.4",
"vue": "^3.2.29",
"vue-tsc": "^0.31.1"
},

View File

@ -1,7 +1,7 @@
import { builtinModules } from 'module'
import { defineConfig, Plugin } from 'vite'
import vue from '@vitejs/plugin-vue'
import resolve from 'vite-plugin-resolve'
import optimizer from 'vite-plugin-optimizer'
import pkg from '../../package.json'
// https://vitejs.dev/config/
@ -41,16 +41,16 @@ export default defineConfig({
* @see https://github.com/caoxiemeihao/electron-vue-vite/issues/52
*/
export function resolveElectron(
resolves: Parameters<typeof resolve>[0] = {}
entries: Parameters<typeof optimizer>[0] = {}
): Plugin {
const builtins = builtinModules.filter((t) => !t.startsWith('_'))
/**
* @see https://github.com/caoxiemeihao/vite-plugins/tree/main/packages/resolve#readme
*/
return resolve({
return optimizer({
electron: electronExport(),
...builtinModulesExport(builtins),
...resolves,
...entries,
})
function electronExport() {