mirror of
https://github.com/electron-vite/electron-vite-vue
synced 2025-01-19 11:56:36 +08:00
feat: use vitejs-plugin-electron
This commit is contained in:
parent
8bbc770d69
commit
e7406e9c13
@ -75,7 +75,8 @@
|
||||
"rollup-plugin-esbuild": "^4.2.3",
|
||||
"ts-node": "^9.1.1",
|
||||
"typescript": "^4.2.4",
|
||||
"vite": "^2.2.4"
|
||||
"vite": "^2.2.4",
|
||||
"vitejs-plugin-electron": "^0.0.4"
|
||||
},
|
||||
"keywords": [
|
||||
"vite",
|
||||
|
@ -3,32 +3,19 @@ require('dotenv').config({ path: join(__dirname, '.env') })
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import { join } from 'path'
|
||||
// import typescript from '@rollup/plugin-typescript'
|
||||
import { builtins } from './script/utils'
|
||||
import {
|
||||
// ensureCwdCrrect,
|
||||
esm2cjs,
|
||||
} from './script/plugins'
|
||||
import electron from 'vitejs-plugin-electron'
|
||||
|
||||
const root = join(__dirname, 'src/render')
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig(env => {
|
||||
const isserve = env.command === 'serve'
|
||||
|
||||
return {
|
||||
plugins: [
|
||||
vue(),
|
||||
...(isserve ? [
|
||||
/**
|
||||
* !!! 开发期将 electron 及相关模块转换成 commonjs 避开 vite 处理
|
||||
*/
|
||||
esm2cjs([
|
||||
'electron',
|
||||
'electron-store',
|
||||
]),
|
||||
] : []),
|
||||
],
|
||||
isserve && electron({}),
|
||||
].filter(Boolean),
|
||||
root,
|
||||
base: './', // index.html 中静态资源加载位置
|
||||
server: {
|
||||
@ -45,7 +32,6 @@ export default defineConfig(env => {
|
||||
optimizeDeps: {
|
||||
exclude: [
|
||||
'electron',
|
||||
// 'electron-store', // optional
|
||||
],
|
||||
},
|
||||
build: {
|
||||
@ -56,10 +42,6 @@ export default defineConfig(env => {
|
||||
assetsDir: '', // 相对路径 加载问题
|
||||
sourcemap: true,
|
||||
rollupOptions: {
|
||||
plugins: [
|
||||
// typescript({ module: 'ESNext' }),
|
||||
// ensureCwdCrrect(join(root, 'main.ts')),
|
||||
],
|
||||
external: [
|
||||
...builtins(),
|
||||
'electron',
|
||||
|
@ -2816,6 +2816,13 @@ vite@^2.2.4:
|
||||
optionalDependencies:
|
||||
fsevents "~2.3.1"
|
||||
|
||||
vitejs-plugin-electron@^0.0.4:
|
||||
version "0.0.4"
|
||||
resolved "https://registry.yarnpkg.com/vitejs-plugin-electron/-/vitejs-plugin-electron-0.0.4.tgz#b6ce83510572cf50c55cc9f35d6a847d7fcd67b4"
|
||||
integrity sha512-mD4weY2OJaDY48i5P4LNYV10wS490MvZG4y9egfve75Qs89nZ6G8mfdRId+3bL36AKGJuvEWLiuzpV0dHSAqwA==
|
||||
dependencies:
|
||||
acorn "^8.2.4"
|
||||
|
||||
vue@^3.0.11:
|
||||
version "3.0.11"
|
||||
resolved "https://registry.yarnpkg.com/vue/-/vue-3.0.11.tgz#c82f9594cbf4dcc869241d4c8dd3e08d9a8f4b5f"
|
||||
|
Loading…
x
Reference in New Issue
Block a user