Reputation: 216
I was being able to do a functional build with vite@1 and now that I have updated my configuration and my modules to work with vite@2, some assets and components do not load correctly and have paths that do not correspond to the real absolute paths.
It works perfect on dev and although I am making an app with electron, it should not be a problem since as I mentioned before the builds were good with vite@1.
It is not a problem with the assets, they exist in the build folder. Seems to be a problem when they are required.
https://github.com/MangoTsing/vite-electron-quick/issues/11
Although I don't think it has to do with electron, again. Still I put it on vite-electron-quick to rule out the possibility.
This is my vite config:
import { join } from 'path'
import { UserConfig } from 'vite'
import dotenv from 'dotenv'
import vue from '@vitejs/plugin-vue'
dotenv.config({ path: join(__dirname, '.env') })
const root = join(__dirname, 'src/render')
const config: UserConfig = {
root,
resolve: {
alias: {
'/@/': root,
}
},
base: './',
build: {
outDir: join('../../dist/render'),
emptyOutDir: true,
assetsInlineLimit: 0
},
server: {
port: +process.env.PORT,
},
plugins: [
vue()
],
optimizeDeps: {
exclude: [
'electron-is-dev',
'electron-store',
]
},
}
export default config
https://github.com/denyncrawford/mismor-guillotine
vite
latest:Upvotes: 0
Views: 3862
Reputation: 216
Solved! This was happening because vue-router's createWebHistory()
can't hanlde the navigation if the app is not being served. It works on dev mode because vite serves the app but when you build and open the file in a browser it doesn't. So you may say: It is pretty basic, well no... The actual problem was being caused because by the drastical change that vite had at vite@2 and the way the starter-code-templates had to adapt to it. I was using vite with electron, so migrating the starter I'm using was kinda a blinded run. I found that the starter is not serving the file anymore but loading the file directly on the electron main.js
, so because I don't know why this is for, I did not serve the file again, instead changed to createWebHashHistory()
at my router config and then it worked!
Upvotes: 1