Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hey guys, does this package ready for production usage? #3

Open
shmatul opened this issue Dec 16, 2016 · 7 comments
Open

Hey guys, does this package ready for production usage? #3

shmatul opened this issue Dec 16, 2016 · 7 comments
Labels

Comments

@shmatul
Copy link

shmatul commented Dec 16, 2016

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.

@villeristi
Copy link
Owner

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.

@mimartinez
Copy link

mimartinez commented Jan 17, 2017

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

@villeristi
Copy link
Owner

@mimartinez could you please show your routes in Express?

@mimartinez
Copy link

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.

@villeristi
Copy link
Owner

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.

@mimartinez
Copy link

mimartinez commented Jan 17, 2017

Very good! Thank you

@dukenst2006
Copy link

Great work ! @villeristi KEEP IT UP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants