Last active
October 17, 2017 12:35
-
-
Save Momciloo/7bd38b3286d07b7080286b820da3631e to your computer and use it in GitHub Desktop.
Serving VueJS in history mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "vueserver", | |
"version": "1.0.0", | |
"description": "A VueJS server", | |
"author": "Momcilo Popov", | |
"private": true, | |
"scripts": { | |
"start": "node server.js" | |
}, | |
"dependencies": { | |
"connect": "^3.6.5", | |
"express": "^4.16.2", | |
"path": "^0.12.7", | |
"serve-static": "^1.13.1" | |
}, | |
"engines": { | |
"node": ">= 4.0.0", | |
"npm": ">= 3.0.0" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var server = express(); | |
server.use('/static', express.static(__dirname + '/static')); | |
server.get('/*', function (req, res) { | |
res.sendFile(__dirname + '/index.html'); | |
}); | |
var port = 8000; | |
server.listen(port, function () { | |
console.log('server listening on port ' + port); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment