You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Been using this boilerplate for dev using react (its great) and I'm having trouble testing sudo production build.
I'm trying to deploy to heroku by adding express server code and a procfile. I do a webpack -p to create the dist folder with its contents (bundle.js, [hash].jpegs).
I then use then express code to provide a way to serve up my simple react app.
`app.use("/static", express.static(path.join(__dirname,'dist')));
//used for referencing images from the bundle.js in the dist folder
The weird thing is that if the 'app.use' line for setting up static reference is commented out, the homepage is rendered in the browser without the images loading simply by returning the bundle.js file from the get request. However if I do leave the app.use line in the code.. the browser just shows raw JS source in the window and does not render the page at all.. This has got me pretty confused, any tips would would be great. Thanks.
The text was updated successfully, but these errors were encountered:
Been using this boilerplate for dev using react (its great) and I'm having trouble testing sudo production build.
I'm trying to deploy to heroku by adding express server code and a procfile. I do a webpack -p to create the dist folder with its contents (bundle.js, [hash].jpegs).
I then use then express code to provide a way to serve up my simple react app.
`app.use("/static", express.static(path.join(__dirname,'dist')));
//used for referencing images from the bundle.js in the dist folder
app.get('*', (req, res) => {
res.sendFile(path.resolve(path.join(__dirname,'dist'), "bundle.js"));
});`
The weird thing is that if the 'app.use' line for setting up static reference is commented out, the homepage is rendered in the browser without the images loading simply by returning the bundle.js file from the get request. However if I do leave the app.use line in the code.. the browser just shows raw JS source in the window and does not render the page at all.. This has got me pretty confused, any tips would would be great. Thanks.
The text was updated successfully, but these errors were encountered: