vue.js-starter-template
vue.js-starter-template copied to clipboard
Hey guys, does this package ready for production usage?
I've tried npm build, seems OK but there's no server running. I've also tried setting NODE_ENV=production and it didn't do the trick.
Hi! The npm run build does what it says: Builds minified & production-ready files under /build directory. Files are static and no server whatsoever is involved within these files. You need to upload these files to your server and configure it to serve the files to browser from that location.
I have my production App with npm run build. Static files of the build folder are in a Static Server in Express Nodejs.
My problem is that, the vue-router does not work. If I put /signin directly it appears
Cannot GET /signin
and '*' route does not work. What server do you use for production? Thank you
@mimartinez could you please show your routes in Express?
My file server.js:
const express = require('express');
const path = require('path');
const serveStatic = require('serve-static');
const app = express();
app.use(serveStatic(path.join(__dirname, 'build')));
const port = process.env.PORT || 8080;
app.listen(port);
console.log(`Our app is running on port ${port}`);
In package.json script "start": "node server.js"
I do not have routes.
Hi, just tested with below code & the static build files and this works.
Note the omitting of serveStatic as Express has this method built in now.
const express = require('express');
const app = express();
app.use(express.static(__dirname + '/build'));
app.get('*', function(req, res){
res.sendFile(__dirname + '/build/index.html');
});
const port = process.env.PORT || 8080;
app.listen(port);
console.log(`Our app is running on port ${port}`);
If this does not work the error has to be in your Vue-router file.
Very good! Thank you
Great work ! @villeristi KEEP IT UP.