Ace
Ace

Reputation: 69

Deliver Html file using Vue.js and express.js

i am using Vue.js as frontend and express.js as Backend. When i start the express.js server with npm start, i would like to deliver the frontend component from Vue.

I am using Vue generator & Express generator, when i deliver the index.html file with

    res.sendFile(path.join(__dirname + '/index.html'));

the browser shows an empyt site, because there is only written.

    <div id="app"></div>

I think i have to build the index.html file first, because the frontend part is divided up in different Vue components (.vue files)

Upvotes: 0

Views: 533

Answers (1)

Marco Pantaleoni
Marco Pantaleoni

Reputation: 2539

Your express server has to serve not only the index.html file but also all the other built js files. If you are using vue-cli, you have to serve all the files that you find in the dist folder after you run npm run build (production mode build).

Upvotes: 1

Related Questions