Change hard coded url constants for different environments via webpack

You can store your API_URL in webpack config: // this config can be in webpack.config.js or other file with constants var API_URL = { production: JSON.stringify(‘prod-url’), development: JSON.stringify(‘dev-url’) } // check environment mode var environment = process.env.NODE_ENV === ‘production’ ? ‘production’ : ‘development’; // webpack config module.exports = { // … plugins: [ new webpack.DefinePlugin({ … Read more

Webpack Dev Server with NGINX proxy_pass

Proxy pass should be ip and port of your webpack-dev-server container and you need proxy_redirect off; location /sockjs-node { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; proxy_pass http://node:8080; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection “upgrade”; } Also don’t forget to add poll to your webpack-dev middleware watchOptions: { aggregateTimeout: 300, … Read more

webpack.validateSchema is not a function

Looks like npm bug, since webpack-dev-server@2.1.0-beta.11 requires webpack@^2.1.0-beta.26 but npm failed to install it. The easiest way to avoid the issue without updating too much is to change dependency in package.json to “webpack-dev-server”: “2.1.0-beta.10”, Instead of something like “webpack-dev-server”: “^2.1.0-beta.9″, “^” char before version says “compatible with”. Removing it sticks to the version exactly. Don’t … Read more

Difference between production and development build in ReactJS

The development build is used – as the name suggests – for development reasons. You have Source Maps, debugging and often times hot reloading ability in those builds. The production build, on the other hand, runs in production mode which means this is the code running on your client’s machine. The production build runs uglify … Read more

Do I need webpack-dev-server if I am using a node server like express

Since I have express server, do I really need webpack-dev-server? Yes and no. You can use a hybrid approach, which essentially setup the webpack-dev-server as a proxy. You have your express server that serves everything except for assets. If it’s an asset, the request gets forwarded/proxied to the webpack-dev-server. See the answer here for more … Read more

Webpack-dev-server doesn’t generate source maps

Use webpack-dev-server -d -d is shorthand for –debug –devtool source-map –output-pathinfo. output-pathinfo adds comments to the generated bundle that explain what module/files are included in what places. So in the generated code, the comment is added to this line of code: require(/* ./test */23) which says that 23 is pointing to the test module. This … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)