12

I'm trying to run a simple vue.js app. My setup is a vue.js 3 app with vite, built according to the tutorial on the official website. (https://vitejs.dev/guide/#command-line-interface) Now I try to deploy that on a cloud and I need the command to run the app. I don't find any information about that. My package.json is lacking the entry for start or run. I don't find any information about the command on the official website. What am I missing?

package.json

{
  "name": "my-vite-app",
  "version": "0.0.0",
  "scripts": {
    "dev": "vite",
    "build": "vite build"
  },
  "dependencies": {
    "vue": "^3.0.4"
  },
  "devDependencies": {
    "@vue/compiler-sfc": "^3.0.4",
    "autoprefixer": "^10.3.5",
    "postcss": "^8.3.7",
    "tailwindcss": "^2.2.15",
    "vite": "^1.0.0-rc.13"
  }
}
user3603819
  • 597
  • 1
  • 4
  • 18
  • what happens after you run `npm build`? Any console messages? – wittgenstein Sep 25 '21 at 09:12
  • We need more information about your deployment environment. You mention cloud, but are you trying to run in a static S3 bucket in AWS, a container somewhere, etc? ```npm run build``` will create the distributable needed to run the app, but we need to know where you are trying to publish the app. – adam Sep 08 '22 at 01:09

2 Answers2

11

You can do it with preview. documentation

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

then

$ npm run build
$ npm run preview
alejandrodotor8
  • 431
  • 5
  • 7
  • 6
    It is important to note that vite preview is intended for previewing the build locally and not meant as a production server. https://vitejs.dev/guide/static-deploy.html#testing-the-app-locally:~:text=It%20is%20important%20to%20note%20that%20vite%20preview%20is%20intended%20for%20previewing%20the%20build%20locally%20and%20not%20meant%20as%20a%20production%20server. – user2704504 Sep 26 '22 at 01:26
2

According to the official docs, "vite build" will create the prod build using your index.html file as entry point. You can also specify another publich patch. Check it out.

Ismael Ordás
  • 370
  • 4
  • 12