react-slingshot icon indicating copy to clipboard operation
react-slingshot copied to clipboard

Create dev/index.html during development (using `npm start -s`)

Open ohenrik opened this issue 5 years ago • 5 comments

I'm about to go crazy due to this magic:


  output: {
    path: path.resolve(__dirname, 'dist'), // Note: Physical files are only output by the production build task `npm run build`.
    publicPath: '/',
    filename: 'bundle.js'
  },

More specifically this: // Note: Physical files are only output by the production build task npm run build

So the question is, how do I make webpack create physical files in dev/? I need this to be able to serve my application through Flask (python) during development as well as production.

ohenrik avatar Sep 28 '18 15:09 ohenrik

If you need physical files, then why not just run the prod build: npm run build?

coryhouse avatar Sep 28 '18 16:09 coryhouse

This would not work with hot reloading during development, right? I seem to remember it being possible to host the files through something like django/flask while still running the webpack solution through npm.

ohenrik avatar Oct 01 '18 08:10 ohenrik

Correct. No hot reloading on prod build. I'd recommend finding a way to run your React app all by itself so you can use npm start. (likely by hitting mock data)

coryhouse avatar Oct 01 '18 12:10 coryhouse

If you really wanted to persist files and have hot reloading in dev mode, you could use a webpack plugin like write-file-webpack-plugin. Obviously out of the scope of react-slingshot, but leaving it here for you if you want to try it out.

I've used it in the past while building a Chrome extension in React. Found it super handy.

nickytonline avatar Oct 01 '18 13:10 nickytonline

Thank you @nickytonline I'll give that a try, it looks like what i need :)

@coryhouse the problem is that i want to test out an authentication logic that uses cookies created by flask-dance for google auth. This cookie is created automatically on the domain of the flask app, so i need to serve the react app from the same domain to be able to access the cookie (i think).

However I'm searching for other ways to do the login process, if you have any tips on this related to flask and/or React using Google login, let me know :))

ohenrik avatar Oct 02 '18 07:10 ohenrik