1

I created a dist folder using npm run build command in my vue project. I put the dist folder at C:\xampp\htdocs\ and then I started the apache server to test the app locally. whenever I type the http://localhost/dist/index.html in my browser, there is only a blank white page. so, is it possible to run production build locally?

max256
  • 35
  • 3
  • 8
  • 1
    This should do the trick: https://stackoverflow.com/a/51129182/2627160 – Matt Saunders Oct 30 '22 at 15:21
  • 1
    Yeah, no need for a XAMPP server here. – kissu Oct 30 '22 at 15:22
  • whenever I run `http-server dist/` it shows this error: http-server : File C:\Users\Max\AppData\Roaming\npm\http-server.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. – max256 Oct 30 '22 at 16:24
  • 1
    You pretty much have your answer, you need to get more privileges: follow the link. – kissu Oct 30 '22 at 16:25

1 Answers1

1

You should probably have something like this in your package.json

"scripts": {
  "preview": "vite preview",
},

supposing you're using Vue3.

Otherwise, serve is a nice alternative to preview an SPA, no need for a XAMPP server. You can install that globally so that you have it on your whole computer.

If you don't have Vite (like in a Vue2 project) or if you want to quickly preview a static app, the command to run is like this

serve dist

PS: you may also need to get admin rights if you're in Windows.

kissu
  • 40,416
  • 14
  • 65
  • 133