vite problem
Answered
West African Lion posted this in #help-forum
West African LionOP
hello
Answered by joulev
@West African Lion try this in your vite.config.ts
export default defineConfig({
// existing stuff
base: "./",
});
25 Replies
West African LionOP
i have a simple vite project with only tailwind and alpine js
any one know why when i do npm run dev every thing work fine
but when i do npm run build
in the index.html
nothing will get load ?
any one know why when i do npm run dev every thing work fine
but when i do npm run build
in the index.html
nothing will get load ?
@joulev where do you deploy and host the website?
West African LionOP
in c pannel
might be a good idea to include that in the title.
sorry, i don't know about cpanel
sorry, i don't know about cpanel
@joulev where do you deploy and host the website?
West African LionOP
the problem is it not even work in after i click index.html after npm run build
only in npm run dev it work
i think the issue is not for the hosting
i should do anything else after npm run build ?
@West African Lion i think the issue is not for the hosting
no the issue is the hosting.
npm run build will build a dist folder. you need to serve that folder with http. clicking on the .html file won't work because it won't be served with http in that way.
the problem is right now your hosting is not serving the bundle (css and js) files correctly.
npm run build will build a dist folder. you need to serve that folder with http. clicking on the .html file won't work because it won't be served with http in that way.
the problem is right now your hosting is not serving the bundle (css and js) files correctly.
actually, i think i know why
you are serving the app under
/nima
but vite expected you to serve the app under root /
West African LionOP
let me cheak it
is this normal it not work after click the index.html after npm run build ?
in the pc not host
yes it's normal, you need to serve the html file via http. clicking the .html file does not serve it via http
@West African Lion try this in your vite.config.ts
export default defineConfig({
// existing stuff
base: "./",
});
Answer
West African LionOP
import { defineConfig } from 'vite'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [
tailwindcss(),
],
})
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [
tailwindcss(),
],
})
either
./
or /nima
West African LionOP
import { defineConfig } from 'vite'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
base: "./",
plugins: [
tailwindcss(),
],
})
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
base: "./",
plugins: [
tailwindcss(),
],
})
like this ?
yup
either
./
or /nima
should work, tho i think both will workWest African LionOP
tnx problem sloved