vue.js-starter-template icon indicating copy to clipboard operation
vue.js-starter-template copied to clipboard

Hey guys, does this package ready for production usage?

Open shmatul opened this issue 8 years ago • 7 comments

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.

shmatul avatar Dec 16 '16 18:12 shmatul

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.

villeristi avatar Jan 08 '17 23:01 villeristi

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 avatar Jan 17 '17 18:01 mimartinez

@mimartinez could you please show your routes in Express?

villeristi avatar Jan 17 '17 20:01 villeristi

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.

mimartinez avatar Jan 17 '17 20:01 mimartinez

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.

villeristi avatar Jan 17 '17 21:01 villeristi

Very good! Thank you

mimartinez avatar Jan 17 '17 22:01 mimartinez

Great work ! @villeristi KEEP IT UP.

dukenst2006 avatar Feb 07 '17 03:02 dukenst2006