Created
April 25, 2018 15:02
-
-
Save SaulGarza/9595845b171c31a0764605e5e3feed29 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//Assuming your file structure looks like below, you | |
//should be able to serve the index.html from server/app.js | |
//**************************************************// | |
// | |
// Project/ | |
// server/ | |
// app.js | |
// /* the rest of your backend */ | |
// client/ | |
// /* all client side files */ | |
// dist/ | |
// index.html | |
// bundle.js | |
// bundle.css | |
// /* whatever assets your build packaged */ | |
// | |
//**************************************************// | |
// | |
// the only file in dist that you should be making yourself | |
// is dist/index.html, where you link the bundle.js and bundle.css | |
// files. usually through >_: create-react-app the command to build | |
// the bundle is `npm run build`, but you can check your package.json | |
// for extra help. | |
app.use('/', (req, res) => { | |
res.sendFile(path.join(__dirname, '../dist', 'index.html'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sidenote. dist stands for distribution. makes it a little easier to understand that the client code is not served, but instead the bundled styles and javascript is served to clients.