So I am using webpack-dev-server and its live reload ability. I am on a windows machine. When I change a js file it seems to be reloading the browser but it doesn't rebuild the bundle. Here is my webpack config file
var webpack = require("webpack"); var path = require('path'); module.exports = { entry: ['./app/thirdparty', "./app/app.js"], output: { filename: "./build/bundle.js", publicPath: "/assets/" }, plugins: [ new webpack.HotModuleReplacementPlugin() ], module: { loaders: [{ test: /\\.js$/, exclude: /node_modules/, loader: "babel-loader" }] }, resolve: { extensions: ['', '.js', '.es6'] }, include: path.join(__dirname, 'app') }
I've tried to run it with
webpack-dev-server
and
webpack-dev-server --hot
But the bundle is not rebuilt
So I solved my own question. I had a file looking like :
output: {
filename: "./build/bundle.js",
publicPath: "/assets/"
}
I changed it to
output : {
path: path.resolve('build/js'),
publicPath: "/public/js/",
filename : "bundle.js",
}
Which means it will create a bundle.js that will end up in /build/js/bundle.js BUT it needs to be referred to in index.html as public/js/bundle.js because of how the publicPath is specified. Also running
webpack-dev-server --inline
Made everything work. Its obvious once you understand web pack I guess...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.