Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in production how to build two html entrance #189

Open
zzxdt opened this issue Apr 29, 2024 · 0 comments
Open

in production how to build two html entrance #189

zzxdt opened this issue Apr 29, 2024 · 0 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@zzxdt
Copy link

zzxdt commented Apr 29, 2024

i make a pron japanese game (galgame) translator and i want to use vite to buidl two entrance like it:
import { fileURLToPath, URL } from 'url'
import { defineConfig, loadEnv } from 'vite'
import ElectronPlugin, { ElectronOptions } from 'vite-plugin-electron'
import RendererPlugin from 'vite-plugin-electron-renderer'
import VuetifyPlugin from 'vite-plugin-vuetify'
import VueJsx from '@vitejs/plugin-vue-jsx'
import Vue from '@vitejs/plugin-vue'
import EslintPlugin from 'vite-plugin-eslint'
import { rmSync } from 'fs'
import { resolve, dirname } from 'path'
import { builtinModules } from 'module'
const isDevEnv = process.env.NODE_ENV === 'development'

export default defineConfig(({ mode }) => {
process.env = {
...(isDevEnv
? {
ELECTRON_ENABLE_LOGGING: 'true'
}
: {}),
...process.env,
...loadEnv(mode, process.cwd())
}

rmSync('dist', { recursive: true, force: true })

const electronPluginConfigs: ElectronOptions[] = [
{
entry: 'src/main/index.ts',
onstart({ startup }) {
startup()
},
vite: {
build: {
assetsDir: '.',
outDir: resolve(__dirname, 'dist/main'),
sourcemap: isDevEnv,
minify: !isDevEnv,
rollupOptions: {
plugins: [
require('@rollup/plugin-alias')({
entries: [{ find: '@', replacement: resolve(__dirname, 'src') }]
})
],
external: ['electron', ...builtinModules, 'koffi']
}
}
}
},
{
entry: 'src/preload/index.ts',
onstart({ reload }) {
reload()
},
vite: {
resolve: {
alias: {
'@': resolve(dirname(fileURLToPath(import.meta.url)), 'src')
}
},
build: {
outDir: 'dist/preload'
}
}
}
]

if (isDevEnv) {
electronPluginConfigs.push({
entry: 'src/main/index.dev.ts',
vite: {
build: {
outDir: 'dist/main'
}
}
})
}

return {
define: {
VUE_I18N_FULL_INSTALL: true,
VUE_I18N_LEGACY_API: false,
INTLIFY_PROD_DEVTOOLS: false
},
resolve: {
extensions: ['.mjs', '.js', '.ts', '.vue', '.json', '.scss'],
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
base: './',
root: resolve(__dirname, 'src/renderer'),
publicDir: resolve(__dirname, './src/renderer/public'),
clearScreen: false,
build: {
sourcemap: isDevEnv,
minify: !isDevEnv,
outDir: resolve('./dist'),
rollupOptions: {
input: {
main: 'index.html', //this is vite input
translator: '../translator/index.html',
}
}
},
server: {
hmr: true
},
plugins: [
Vue(),
VueJsx(),
// Docs: https://github.com/vuetifyjs/vuetify-loader
VuetifyPlugin({
autoImport: true
}),
// EslintPlugin(),
// Docs: https://github.com/electron-vite/vite-plugin-electron
ElectronPlugin(electronPluginConfigs),
RendererPlugin()
]
}
})
but its wrong :Could not resolve entry module "../translator/index.html".
error during build:
RollupError: Could not resolve entry module "../translator/index.html".
at error (file:///D:/nodejs/node_globle/node_modules/vite/node_modules/rollup/dist/es/shared/parseAst.js:337:30)
at ModuleLoader.loadEntryModule (file:///D:/nodejs/node_globle/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:17957:20)
at async Promise.all (index 1)
how to resolve it? i really need it

@zzxdt zzxdt added the bug Something isn't working label Apr 29, 2024
@jooy2 jooy2 added help wanted Extra attention is needed and removed bug Something isn't working labels May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants