Answer the question
In order to leave comments, you need to log in
Webpack HMR: not updating js file or looping reload?
Straight to the point, here's the config, it's not big:
import path from 'path';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import BrowserSyncHotPlugin from 'browser-sync-dev-hot-webpack-plugin';
import webpack from 'webpack';
let webpackConfig = {
entry: {
app: [
'webpack-hot-middleware/client',
path.join(__dirname, 'src/js/app.js'),
path.join(__dirname, 'src/sass/app.scss'),
]
},
output: {
filename: 'js/[name].js',
path: path.join(__dirname, 'dist'),
publicPath: 'http://localhost:3000/'
},
module: {
rules: [
{
test: /\.js$/,
include: path.join(__dirname, 'src/js'),
loader: "babel-loader"
},
{
test: /\.scss$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader', 'sass-loader']
})
}
]
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new ExtractTextPlugin({
filename: 'css/app.css',
disable: true,
}),
new BrowserSyncHotPlugin({
browserSync: {
reloadDelay: 500,
proxy: {
target: 'http://gorch.loc/'
},
plugins: [
{
module: 'bs-html-injector',
options: {
files: './*.html'
}
}
]
},
devMiddleware: {
publicPath: 'http://localhost:3000/'
},
hotMiddleware: {
},
callback() {
console.log('Callback')
}
})
]
};
module.exports = webpackConfig;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question