Webpack-dev-server compiles files but does not refresh or make compiled javascript available to browser

Two things were causing my problems here: module.exports = { entry: ‘./src/index.js’, output: { // For some reason, the `__dirname` was not evaluating and `/public` was // trying to write files to a `public` folder at the root of my HD. path: __dirname + ‘/public’, // Public path refers to the location from the _browser’s_ … Read more

How to pass .env file variables to webpack config?

You can use dotenv package for this purpose. npm install dotenv –save After installing the package, add this in the top of your config: const webpack = require(‘webpack’); // only add this if you don’t have yet // replace accordingly ‘./.env’ with the path of your .env file require(‘dotenv’).config({ path: ‘./.env’ }); then in plugins … Read more

webpack can’t find module if file named jsx

Webpack doesn’t know to resolve .jsx files implicitly. You can specify a file extension in your app (import App from ‘./containers/App.jsx’;). Your current loader test says to use the babel loader when you explicitly import a file with the jsx extension. or, you can include .jsx in the extensions that webpack should resolve without explicit … Read more

I am getting an “Invalid Host header” message when connecting to webpack-dev-server remotely

The problem occurs because webpack-dev-server 2.4.4 adds a host check. You can disable it by adding this to your webpack config: devServer: { compress: true, disableHostCheck: true, // That solved it } Please note, this fix is insecure. Please see this answer for a secure solution. The option was refactored in version 4.0.0. The allowedHosts … Read more

How to make the webpack dev server run on port 80 and on 0.0.0.0 to make it publicly accessible?

Something like this worked for me. I am guessing this should work for you. Run webpack-dev using this webpack-dev-server –host 0.0.0.0 –port 80 And set this in webpack.config.js entry: [ ‘webpack-dev-server/client?http://0.0.0.0:80’, config.paths.demo ] Note If you are using hot loading, you will have to do this. Run webpack-dev using this webpack-dev-server –host 0.0.0.0 –port 80 … Read more

CORS error on request to localhost dev server from remote site

Original Answer I finally found the answer, in this RFC about CORS-RFC1918 from a Chrome-team member. To sum it up, Chrome has implemented CORS-RFC1918, which prevents public network resources from requesting private-network resources – unless the public-network resource is secure (HTTPS) and the private-network resource provides appropriate (yet-undefined) CORS headers. There’s also a Chrome flag … Read more

Chrome CORS error on request to localhost dev server from remote site

Original Answer I finally found the answer, in this RFC about CORS-RFC1918 from a Chrome-team member. To sum it up, Chrome has implemented CORS-RFC1918, which prevents public network resources from requesting private-network resources – unless the public-network resource is secure (HTTPS) and the private-network resource provides appropriate (yet-undefined) CORS headers. There’s also a Chrome flag … Read more

CORS error even after setting Access-Control-Allow-Origin or other Access-Control-Allow-* headers on client side

Access-Control-Allow-Origin is a response header the server the request goes to must send. And all other Access-Control-Allow-* headers are response headers for servers to send. If you don’t control the server your request is sent to, and the problem with the response is just the lack of the Access-Control-Allow-Origin header or other Access-Control-Allow-* headers you … Read more

tech