React localhost problem with http => https - reactjs

I used the instructions from the official react documentation, but localhost still starts from http://.
My package.json file where I tried to add a solution.
I also tried 'set HTTPS = true && npm start'.
{
"name": "project",
"version": "1.0.0",
"description": "Project",
"main": "webpack.config.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack -p",
"start": "webpack-dev-server --hot --inline -d && HTTPS=true react-scripts start",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"#babel/polyfill": "^7.8.7",
"formik": "^2.1.4",
"ramda": "^0.27.0",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react-https-redirect": "^1.1.0",
"react-iframe": "^1.8.0",
"react-router-dom": "^5.0.1",
"react-scripts": "^3.4.1",
"react-scroll-up-button": "^1.6.4",
"styled-components": "^5.0.1",
"whatwg-fetch": "^3.0.0"
},
"devDependencies": {
"#babel/core": "^7.7.5",
"#babel/plugin-proposal-async-generator-functions": "^7.8.3",
"#babel/plugin-proposal-class-properties": "^7.7.4",
"#babel/plugin-transform-async-to-generator": "^7.8.3",
"#babel/plugin-transform-regenerator": "^7.8.7",
"#babel/preset-env": "^7.7.6",
"#babel/preset-react": "^7.7.4",
"autoprefixer": "^9.6.1",
"babel-loader": "^8.0.6",
"css-loader": "^3.2.0",
"file-loader": "^4.2.0",
"gh-pages": "^2.2.0",
"html-webpack-plugin": "^3.2.0",
"node-sass": "^4.12.0",
"postcss-loader": "^3.0.0",
"react-inlinesvg": "^1.2.0",
"sass-loader": "^7.2.0",
"style-loader": "^1.0.0",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10",
"webpack-dev-server": "^3.9.0"
}
}
webpackconfig.js
const path = require("path");
const Html = require('html-webpack-plugin');
module.exports = {
entry: [
"whatwg-fetch",
"./js/index.js",
],
output: {
filename: "js/out.js",
path: path.resolve(__dirname, "build")
},
devServer: {
port: 3001,
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
}
},
{
test: /\.scss$/,
use: [
'style-loader',
'css-loader',
{
loader: "postcss-loader",
options: {
plugins: () => [
require("autoprefixer")()
],
},
},
'sass-loader',
]
},
{
test: /\.(jpg|jpeg|gif|png)$/,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]',
publicPath: 'images',
outputPath: 'images',
}
}
},
{
test: /\.(eot|ttf|woff|woff2)$/,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]',
publicPath: 'fonts',
outputPath: 'fonts',
}
}
},
]
},
plugins: [
new Html({
filename: 'index.html',
template: './index.html',
})
]
};
I'm a beginner and I can't deal with it, if someone can help me, I will be very grateful.

The options for SET HTTPS=true are for projects that are made with create-react-app. Since you have a webpack configuration file of your own, you have to change the configuration for enabling HTTPS.
You can do this with:
devServer: {
https: true
}
This enables a self signed certificate. You can provide a certifiate with:
devServer: {
https: true,
key: fs.readFileSync('/path/to/server.key'),
cert: fs.readFileSync('/path/to/server.crt'),
ca: fs.readFileSync('/path/to/ca.pem'),
}
Docs

In package.json try add set HTTPS=true instead of HTTPS=true in start script.

Related

Deploying react app on on Netlify is success and published, but Page Not Found

React app with Webpack, babel deployed over netlify showing Page Not Found though the downloaded build is working fine in local.
I've deployed using netlify drop pane by drag-n-drop react app folder. Not with github.
Netlify community topic link for the same -
https://community.netlify.com/t/page-not-found-error-downloaded-build-working-in-local-but-not-on-netlify-site/20094
Here't the site - https://gracious-roentgen-c5c8be.netlify.app/
Build Status -
Published deploy
Production. Today at 10:38 AM  Download ready
Deploy log -
10:38:22 AM: Starting post processing
10:38:22 AM: Post processing - HTML
10:38:23 AM: Post processing - redirect rules
10:38:23 AM: Post processing - header rules
10:38:23 AM: Post processing done
10:38:23 AM: Site is live
Here's my webpack.config.js:
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: ['./src/index.js', '#babel/polyfill'],
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['#babel/preset-react', '#babel/preset-env'],
},
},
},
{
test: /\.css$/i,
exclude: /node_modules/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
modules: true,
},
},
],
},
{
test: /\.(jpe?g|gif|png|svg)$/i,
use: [
{
loader: 'url-loader',
options: {
limit: 10000,
},
},
],
},
{
test: /\.(gif|png|jpe?g)$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'assets/images/',
},
},
],
},
// {
// loader: 'babel-loader',
// options: {
// presets: ['#babel/react', '#babel/env', '#babel/preset-env'],
// },
// },
],
// loaders: [{ test: /\.jsx?$/, loader: 'babel' }],
},
devServer: {
host: '192.168.1.10', //your ip address,
// host: '0.0.0.0', //your ip address,
historyApiFallback: true,
contentBase: '././src',
port: 8080,
disableHostCheck: true,
},
resolve: {
extensions: ['*', '.js', '.jsx'],
},
output: {
path: path.join(__dirname, '/dist'),
filename: 'bundle.js',
publicPath: '/',
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new HtmlWebpackPlugin({
template: path.resolve('./dist/index.html'),
}),
],
devServer: {
// contentBase: './dist',
contentBase: './build',
hot: true,
},
};
Package.json:
{
"name": "dljalpha",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server --mode development --open --hot --host 0.0.0.0",
"test": "jest",
"build": "webpack --mode production"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"#babel/core": "^7.8.7",
"#babel/polyfill": "^7.10.1",
"#babel/preset-env": "^7.10.2",
"#babel/preset-react": "^7.10.4",
"axios-mock-adapter": "^1.18.1",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.0.6",
"css-loader": "^3.5.3",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"eslint": "^6.8.0",
"eslint-config-airbnb": "^18.1.0",
"eslint-config-prettier": "^6.11.0",
"eslint-loader": "^4.0.2",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-react": "^7.19.0",
"eslint-plugin-react-hooks": "^2.5.0",
"file-loader": "^6.0.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^26.0.1",
"prettier": "^2.0.5",
"react-hot-loader": "^4.12.19",
"redux-mock-store": "^1.5.4",
"style-loader": "^1.2.1",
"url-loader": "^4.1.0",
"webpack": "^4.42.0",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.10.3"
},
"dependencies": {
"#material-ui/core": "^4.10.2",
"#material-ui/icons": "^4.9.1",
"#material-ui/lab": "^4.0.0-alpha.56",
"axios": "^0.19.2",
"core-js": "^3.6.5",
"html-webpack-plugin": "^4.3.0",
"husky": "^4.2.5",
"prop-types": "^15.7.2",
"react": "^16.13.0",
"react-dom": "^16.13.0",
"react-intl": "^4.6.3",
"react-redux": "^7.2.0",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react-share": "^4.2.1",
"react-test-renderer": "^16.13.1",
"recompose": "^0.30.0",
"redux": "^4.0.5",
"redux-saga": "^1.1.3",
"regenerator-runtime": "^0.13.5"
}
}
Please guide. Thanks
Netlify drop will not build your app for you. You need to drop the dist folder that appear when running npm run build.
I advice you to use the git workflow with netlify, if you do netlify will build your app and it will be easier for you to update your website. For this you need to push your code to a github repository and create an app from git in netlify.

I am trying to rReduce my react JS Bundle Size

I am trying to reduce the size of my build file ( main.js 432 KiB ), it's a small widget!
I have tried compression-webpack-plugin and DefinePlugin but in vain, the size stays the same, do i need these two extensions, code splitting is not an option because it's a small widget with one component. I would appreciate any feedback. Tks.
Bellow you can find my webpack.config.js
var webpack = require('webpack');
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var CompressionPlugin = require('compression-webpack-plugin');
module.exports = {
entry: ['#babel/polyfill', './app/index.js'],
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'main.js'
},
module: {
rules: [
{ test: /\.(js)$/, use: 'babel-loader' },
{ test: /\.(css|scss)$/, use: [ 'style-loader', 'css-loader', 'sass-loader', 'cssimportant-loader' ] },
{ test: /\.(jpe?g|png|ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/, use: 'base64-inline-loader?limit=1000&name=[name].[ext]' }
]
},
devtool: 'source-map',
plugins: [
new HtmlWebpackPlugin({
template: './app/index.html',
minify: {
collapseWhitespace: true
}
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new webpack.optimize.AggressiveMergingPlugin(),
new CompressionPlugin({
filename: "[path].gz[query]",
algorithm: "gzip",
test: /\.js$|\.css$|\.html$/,
threshold: 10240,
minRatio: 0.8
})
]
};
And here is my package.json
{
"name": "my-wdg",
"version": "1.0.0",
"description": "",
"main": "index.js",
"babel": {
"presets": [
"#babel/preset-env",
"#babel/preset-react"
],
"plugins": [
"#babel/plugin-proposal-class-properties"
]
},
"scripts": {
"clean": "rimraf dist",
"start": "webpack-dev-server --open",
"dist": "webpack -p --mode=production",
"watch": "webpack --config webpack.config.js --watch",
"build": "cross-env NODE_ENV=production npm run clean && webpack -p"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"cleanslate": "^0.10.1",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"resolve": "^1.13.1"
},
"devDependencies": {
"#babel/core": "^7.7.5",
"#babel/plugin-proposal-class-properties": "^7.7.4",
"#babel/polyfill": "^7.7.0",
"#babel/preset-env": "^7.7.6",
"#babel/preset-react": "^7.7.4",
"axios": "^0.19.0",
"babel-loader": "^8.0.6",
"base64-inline-loader": "^1.1.1",
"compression-webpack-plugin": "^3.1.0",
"cross-env": "^7.0.2",
"css-loader": "^3.3.0",
"cssimportant-loader": "^0.4.0",
"file-loader": "^4.3.0",
"html-webpack-plugin": "^3.2.0",
"mini-css-extract-plugin": "^0.7.0",
"node-sass": "^4.14.1",
"react-meta-tags": "^0.7.4",
"react-router-dom": "^5.1.2",
"react-structured-data": "0.0.14",
"sass-loader": "^7.3.1",
"style-loader": "^0.23.1",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10",
"webpack-dev-server": "^3.11.0",
"webpack-provide-global-plugin": "0.0.1"
}
}

React 16v - Uncaught TypeError: Cannot read property 'bool' of undefined

I updated my project's react version from 15.3.1 to 16.2.0. I'm getting the following runtime error message.
Uncaught TypeError: Cannot read property 'bool' of undefined
at eval (Transition.js?0efa:259)
at Object.<anonymous> (bundle.js:4059)
at __webpack_require__ (bundle.js:1337)
at fn (bundle.js:744)
at eval (398:19)
at Object.<anonymous> (bundle.js:3348)
at __webpack_require__ (bundle.js:1337)
at fn (bundle.js:744)
at eval (99:30)
at Object.<anonymous> (bundle.js:1647)
I did the update gradually and the app worked well in 15.6.2. The error started appearing after I updated it to 16.0.0. I updated it to 16.2.0 hoping it would resolve it. But no luck. My webpack.config.js and package.json is below
package.json
{
"name": "myProject",
"version": "28.0.0",
"description": "New front end",
"main": "main.js",
"scripts": {
"test": "jest",
"test-coverage": "jest --coverage",
"dev": "webpack --config webpack.config.js -d --watch",
"build": "webpack --config ./webpack.config.production.js --progress -p",
"start": "webpack-dev-server --config ./webpack.config.js --hot"
},
"repository": "",
"author": "Sarani",
"license": "BSD",
"dependencies": {
"babel": "~6.5.2",
"babel-core": "~6.13.2",
"babel-loader": "~6.2.4",
"babel-polyfill": "~6.16.0",
"babel-preset-es2015": "~6.13.2",
"babel-preset-react": "~6.11.1",
"create-react-class": "^15.6.3",
"css-loader": "~0.18.0",
"file-loader": "~0.9.0",
"isomorphic-fetch": "~2.2.1",
"json-loader": "~0.5.4",
"less": "~2.7.1",
"less-loader": "~2.2.3",
"moment-range": "~3.0.3",
"moment-timezone": "~0.5.13",
"prop-types": "^15.6.0",
"react": "^16.0.0",
"react-bootstrap": "~0.30.2",
"react-dom": "^16.0.0",
"react-redux": "~4.4.5",
"react-router": "^3.2.0",
"redux": "~3.5.2",
"redux-immutable-state-invariant": "~1.2.3",
"redux-thunk": "~2.1.0",
"style-loader": "~0.13.1",
"url-loader": "~0.5.7",
"webpack": "^3.10.0"
},
"devDependencies": {
"babel-eslint": "~6.1.2",
"babel-jest": "~14.1.0",
"eslint": "~3.5.0",
"eslint-config-airbnb": "~11.1.0",
"eslint-loader": "~1.5.0",
"eslint-plugin-import": "~1.15.0",
"eslint-plugin-jsx-a11y": "~2.2.2",
"eslint-plugin-react": "~6.2.2",
"gulp": "~3.9.1",
"gulp-csslint": "~1.0.0",
"gulp-watch": "~4.3.10",
"jest": "~14.1.0",
"jest-cli": "~14.1.0",
"react-a11y": "~0.3.3",
"react-addons-test-utils": "~15.3.2",
"react-test-renderer": "~15.3.1",
"redux-mock-store": "~1.2.1",
"webpack-dev-server": "~1.14.1"
},
"jest": {
"automock": false,
"moduleNameMapper": {
"^.+\\.(css|less)$": "<rootDir>/__mocks__/styleMock.js",
"^.+\\.(gif|ttf|eot|svg)$": "<rootDir>/__mocks__/fileMock.js",
"^config$": "<rootDir>/__mocks__/configMock.js"
},
"moduleFileExtensions": [
"js",
"jsx"
]
}
}
webpack.config.js
var webpack = require('webpack');
var path = require('path');
module.exports = {
devtool: 'eval-source-map',
entry: {
bundle: ['babel-polyfill', './Main.js'],
bundleIntegrated: ['babel-polyfill', './MainIntegrated.js']
},
output: {
path: path.resolve(__dirname, '../assets/myProject'),
filename: '../assets/myProject/[name].js'
},
target: 'web',
devServer: {
inline: true,
port: 8080,
proxy: {
'/myct/**': {
target: 'http://localhost:9000',
secure: false,
changeOrigin: true
}
}
},
plugins: [
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin()
],
resolve: {
extensions: ['.js', '.jsx'],
alias: {
config: path.join(__dirname, 'config/config.dev')
}
},
module: {
rules: [
{
test: /.(js|jsx)$/,
enforce: 'pre',
exclude: /node_modules/,
use: [
{
loader: "eslint-loader",
}
],
},
{
test: /\.(js|jsx)$/,
exclude: /(node_modules|__tests__)/,
loader: "babel-loader",
},
{
test: /\.css$/,
use: [
"style-loader",
"css-loader",
],
},
{
test: /\.less$/,
use: [
"style-loader",
"css-loader",
"less-loader",
],
},
{
test: /\.woff($|\?)|\.woff2($|\?)|\.ttf($|\?)|\.eot($|\?)|\.svg($|\?)/,
use: [
{
loader: "file-loader?name=../assets/myProject/fonts/[name].[ext]",
},
],
},
]
}
}
Any ideas on how to fix this issue. Thanks in advance :)
I had the same issue.
If you run yarn info react-bootstrap peerDependencies, you will see the following:
{
react: '>=16.8.0',
'react-dom': '>=16.8.0'
}
So, make sure the versions are correct.
I've fixed it by running yarn add react#latest and also yarn add react-dom#latest. In addition, I set react-bootstrap to 0.32.4, as version 1.0.0 threw different errors.
"react": "^16.13.1",
"react-bootstrap": "0.32.4",
"react-dom": "^16.13.1",
Thank you all for your help. I managed to fix the issue by updating the following to latest versions. The solution can be found here
"react": "latest",
"react-dom": "latest",
"react-bootstrap": "latest",
"react-router-dom": "latest"

Webpack, babel and React Error message

Out of nowhere I started getting this error message,
Invalid configuration object. Webpack has been initialised using a
configuration object that does not match the API schema.
- configuration has an unknown property 'devserver'. These properties are valid: object { amd?, bail?, cache?, context?, dependencies?,
devServer?, devtool?, entry, externals?, loader?, module?, name?,
node?, output?, performance?, plugins?, profile?, recordsInputPath?,
recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, stats?,
target?, watch?, watchOptions? } For typos: please correct them.
For loader options: webpack 2 no longer allows custom properties in
configuration.
Loaders should be updated to allow passing options via loader options in module.rules.
Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader:
plugins: [
new webpack.LoaderOptionsPlugin({
// test: /.xxx$/, // may apply this only for some modules
options: {
devserver: ...
}
})
]
I have been scouring the internet for the past 2 hours trying to find a solution but I am going round in circles!
Here is my .babelrc, webpack.config.js, .js and package.json files.
Any help would be amazing. Thanks
.babelrc
{
"presets":[
"react",
["es2015", {"modules": false, "loose": true}]
]
}
package.json
{
"name": "complete-intro-to-react",
"version": "1.0.0",
"description": "A two day workshop on a complete intro to React",
"main": "index.js",
"author": "Brian Holt <btholt#gmail.com>",
"license": "MIT",
"scripts": {
"test": "NODE_ENV=test jest",
"update-test": "npm run test -- -u",
"build": "webpack",
"dev": "webpack-dev-server",
"lint": "eslint js/**/*.js webpack.config.js",
"watch": "webpack --watch"
},
"dependencies": {
"axios": "0.15.2",
"express": "4.14.0",
"history": "^4.4.0",
"lodash": "4.16.2",
"preact": "^6.4.0",
"preact-compat": "^3.9.3",
"react": "15.3.2",
"react-dom": "15.3.2",
"react-redux": "4.4.0",
"react-router": "4.0.0-alpha.5",
"redux": "3.3.1",
"redux-thunk": "^2.1.0"
},
"devDependencies": {
"babel-core": "^6.16.0",
"babel-jest": "16.0.0",
"babel-loader": "^6.2.7",
"babel-plugin-transform-es2015-modules-commonjs": "^6.18.0",
"babel-polyfill": "^6.16.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-es2017": "6.16.0",
"babel-preset-react": "^6.16.0",
"babel-register": "6.16.0",
"css-loader": "0.25.0",
"enzyme": "2.0.0",
"enzyme-to-json": "^1.3.0",
"eslint": "3.6.1",
"eslint-config-standard": "6.1.0",
"eslint-config-standard-jsx": "3.1.0",
"eslint-config-standard-react": "4.1.0",
"eslint-loader": "1.3.0",
"eslint-plugin-promise": "2.0.1",
"eslint-plugin-react": "6.3.0",
"eslint-plugin-standard": "2.0.0",
"jest": "15.1.1",
"jsdom": "9.5.0",
"json-loader": "0.5.4",
"react-addons-test-utils": "15.3.2",
"react-test-renderer": "15.3.2",
"style-loader": "0.13.1",
"webpack": "^2.1.0-beta.22",
"webpack-dev-server": "1.16.2"
},
"directories": {
"test": "test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/btholt/complete-intro-to-react.git"
},
"keywords": [
"react",
"workshop",
"intro",
"redux"
],
"bugs": {
"url": "https://github.com/btholt/complete-intro-to-react/issues"
},
"homepage": "https://github.com/btholt/complete-intro-to-react#readme"
}
webpack.config.js
const path = require('path')
module.exports = {
context: __dirname,
entry: './js/ClientApp.js',
devtool: 'source-map',
output: {
path: path.join(__dirname, '/public'),
filename: 'bundle.js'
},
devserver: {
publicPath: '/public/'
},
resolve: {
extensions: ['.js', '.json']
},
stats: {
colors: true,
reasons: true,
chunks: false
},
module: {
rules: [
{
enforce: 'pre',
test: /\.js$/,
loader: 'eslint-loader',
exclude: /node_modules/
},
{
test: /\.(js|jsx)$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.css$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
url: true
}
}
]
}
]
}
}
and the .js file
import React from 'react'
import { render } from 'react-dom'
import '../public/normalize.css'
import '../public/style.css'
const App = React.createClass({
render () {
return (
<div className='app'>
<div className="landing">
<h1>svideo</h1>
<input type="text" placeholder='search' />
<a>or Browse All</a>
</div>
</div>
)
}
})
render(<App/>, document.getElementById('app'));
Capital "S" -->devServer not devserver!

React hot loader not realoading after changes

I have the following webpack.config.js :
"use strict";
const debug = process.env.NODE_ENV !== "production";
const webpack = require('webpack');
const path = require('path');
module.exports = {
devtool: debug ? 'inline-sourcemap' : null,
devServer: {
inline: true,
port: 3333,
hot: true,
contentBase: "src/static/",
historyApiFallback: {
index: '/index-static.html'
}
},
entry: [
'webpack-dev-server/client?http://localhost:3000/',
'webpack/hot/only-dev-server',
'./src/app-client.js'
],
output: {
path: path.join(__dirname, 'src', 'static', 'js'),
publicPath: "/js/",
filename: 'bundle.js'
},
module: {
loaders: [{
test: path.join(__dirname, 'src'),
loader: ['babel-loader'],
query: {
cacheDirectory: 'babel_cache',
presets: debug ? ['react', 'es2015', 'react-hmre'] : ['react', 'es2015']
}
},
{ test: /\.jsx?$/, loaders: ['react-hot', 'jsx?harmony'], include: path.join(__dirname, 'src') }
]
},
plugins: debug ? [] : [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: { warnings: false },
mangle: true,
sourcemap: false,
beautify: false,
dead_code: true
}),
]
};
package.json
{
"name": "judo-heroes",
"version": "1.0.0",
"description": "Simple application to showcase how to achieve universal rendering and routing with React and Express.",
"main": "src/server.js",
"repository": "git#github.com:lmammino/judo-heroes.git",
"scripts": {
"start": "NODE_ENV=development node_modules/.bin/babel-node --presets 'react,es2015' src/server.js",
"start-dev": "npm run start-dev-hmr",
"start-dev-single-page": "node_modules/.bin/http-server src/static",
"start-dev-hmr": "node_modules/.bin/webpack-dev-server --progress --inline --hot",
"build": "NODE_ENV=development node_modules/.bin/webpack -d"
},
"author": "Luciano Mammino",
"license": "MIT",
"dependencies": {
"babel-cli": "^6.11.4",
"babel-core": "^6.13.2",
"babel-loader": "^6.2.5",
"babel-plugin-react-html-attrs": "^2.0.0",
"babel-preset-es2015": "^6.13.2",
"babel-preset-react": "^6.11.1",
"babel-preset-react-hmre": "^1.1.1",
"ejs": "^2.5.1",
"express": "^4.14.0",
"react": "^15.3.1",
"react-dom": "^15.3.1",
"react-router": "^2.6.1"
},
"devDependencies": {
"http-server": "^0.9.0",
"react-hot-loader": "^1.3.0",
"webpack": "^1.13.2",
"webpack-dev-server": "^1.14.1"
}
}
I am trying to get the browser to refresh every time I make changes to some of the components, but the changes don't take place.
Your issue is probably that you don't get to the loader with test test: /\.jsx?$/, since the first loader matches.
Can you try to use react-hot in the first module?
{
test: path.join(__dirname, 'src'),
loader: ['react-hot','babel-loader'],
query: {
cacheDirectory: 'babel_cache',
presets: debug ? ['react', 'es2015', 'react-hmre'] : ['react', 'es2015']
}
},
A more precise test for this loader would be better in the long run though.
I simply had to run this command:
"start-dev-hmr": "node_modules/.bin/webpack-dev-server --progress --inline --hot",
from
{
"name": "judo-heroes",
"version": "1.0.0",
"description": "Simple application to showcase how to achieve universal rendering and routing with React and Express.",
"main": "src/server.js",
"repository": "git#github.com:lmammino/judo-heroes.git",
"scripts": {
"start": "NODE_ENV=production node_modules/.bin/babel-node --presets 'react,es2015' src/server.js",
"start-dev": "npm run start-dev-hmr",
"start-dev-single-page": "node_modules/.bin/http-server src/static",
"start-dev-hmr": "node_modules/.bin/webpack-dev-server --progress --inline --hot",
"build": "NODE_ENV=production node_modules/.bin/webpack -p"
},
"author": "Luciano Mammino",
"license": "MIT",
"dependencies": {
"babel-cli": "^6.11.4",
"babel-core": "^6.13.2",
"babel-loader": "^6.2.5",
"babel-plugin-react-html-attrs": "^2.0.0",
"babel-preset-es2015": "^6.13.2",
"babel-preset-react": "^6.11.1",
"babel-preset-react-hmre": "^1.1.1",
"ejs": "^2.5.1",
"express": "^4.14.0",
"react": "^15.3.1",
"react-dom": "^15.3.1",
"react-router": "^2.6.1"
},
"devDependencies": {
"http-server": "^0.9.0",
"react-hot-loader": "^1.3.0",
"webpack": "^1.13.2",
"webpack-dev-server": "^1.14.1"
}
}

Resources