카테고리 없음

vue deploy into heroku 뷰 배포

EasyCoding 2021. 2. 19. 15:32
728x90

www.youtube.com/watch?v=UftutR5hz3U

npm i -g @vue/cli

vue create vue_test

cd vue_test

npm run serve

 http://localhost:8080/

npm run build

npm i express serve-static --save

server.js

const express = require('express')
const serverStatic = require('serve-static')
const path = require('path')

const app = express()
const port = process.env.PORT || 3000

// SERVES FILES from our dist directory which now contains out index.html
app.use('/', serverStatic(path.join(__dirname, '/dist')))
app.listen(port)
console.log('Listening on port:' + port)
// app.get('/', (req, res) => res.send('Hello World!'))
// app.listen(port, () => console.log(`Example app listening on port port!`))

 

Add below on package.json 

"start": "node server.js"

 

Important!!!

remove "/dist" on .gitignore

Create an App in Heroku

heroku login

git init

heroku git:remote -a vue-test-hj

git add .

git commit -am "make it better"

git push heroku master

Github와 자동 연동

www.youtube.com/watch?v=5TA99s-K0wM

 

깃허브에 올리고 업데이트 되는데는 2~3분 걸림