3
I’m new to this React and Webpack thing, and I’m studying a lot, but I’ve come up with a problem that I’m not finding a way to solve.
const webpack = require('webpack')
module.exports = {
entry: './html/js/index.jsx',
output: {
path: __dirname + '/deploy/assets/',
publicPath: '/deploy/assets/',
filename: './js/bundle.js'
},
devServer: {
port: 8080,
contentBase: './deploy'
},
resolve: {
extensions: ['', '.js', '.jsx']
},
module: {
loaders: [{
test: /.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['es2015', 'react'],
plugins: ['transform-object-rest-spread']
}
}]
}
}
This is my webpack.config.js.
The problem is, that even though I saved my files in the project and the webpack showing on the console that was compiled, the screen doesn’t show my changes. I’ve even tried going the localhost:8080/webpack-dev-server way to see if my changes were there, and they were!
Even though they are there, my HTML does not update, forcing me to run . /Node-modules/. bin/webpack again to work.
Does anyone have any idea?
Tried using webpack -w? A tip, if you’re working with React, use the Create React App. So you don’t have to waste time with any config, just working with React.
– dsantoro
Are you using the browser with the console on so it won’t cache? otherwise the browser tries to save the connection and doesn’t update the files. Try opening the address in another briwser.
– Sergio
@dsantoro already tried using -w and nothing. I’m creating an application from scratch so I understand how it works, maybe I’m forgetting to install something, I don’t know... It’s pretty weird
– Guilherme Leonardo Utzig
@Sergio also tried on other browsers, nothing...
– Guilherme Leonardo Utzig
@Guilhermeleonardoutzig now understood what you said. You want to use the webpack server’s hot Reload. Something like "start": "webpack && webpack-dev-server --inline --port XXXX" in your package.json. But I still suggest using the Creat Reatc App
– dsantoro
@dsantoro Tranquil, I will research on this. Thank you!
– Guilherme Leonardo Utzig