gpt4 book ai didi

javascript - webpack-dev-server - 浏览器不刷新

转载 作者:行者123 更新时间:2023-11-29 18:00:34 25 4
gpt4 key购买 nike

我在 Mac OSX 上的 2 个独立终端上运行 webpack --watchwebpack-dev-server。每次我更新文件时,它都会在终端中重新编译,但是浏览器不会重新加载,我每次都必须手动重新加载。我已经安装了所有必需的加载器。

Webpack.config.js

var WebpackDevServer = require("webpack-dev-server");
var webpack = require('webpack');
var path = require('path');
require("babel-polyfill");

var BUILD_DIR = path.resolve(__dirname, 'build');
var APP_DIR = path.resolve(__dirname, 'src');

module.exports = {
entry: [
'babel-polyfill',
'bootstrap-loader',
'webpack/hot/dev-server',
APP_DIR + '/import.js',
],
output: {
path: BUILD_DIR,
filename: 'bundle.js'
},
module: {
loaders: [{
test: /\.jsx?$/,
loaders: ['react-hot', 'babel?presets[]=es2015,presets[]=stage-0,presets[]=react,plugins[]=transform-runtime'],
exclude: /node_modules/
}, {
test: /\.css$/,
loader: "style-loader!css-loader"
}, {
test: /\.scss$/,
loaders: ["style", "css", "sass"]
}, {
test: /\.(png|woff|woff2|eot|ttf|svg|jpg|gif)$/,
loader: 'url-loader?limit=100000'
}]
},
plugins: [
new webpack.OldWatchingPlugin(),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
]
};

最佳答案

尝试设置这个入口点

  entry: [
'babel-polyfill',
'bootstrap-loader',
'webpack-dev-server/client?http://localhost:3000',
'webpack/hot/only-dev-server',
APP_DIR + '/import.js',
]

关于javascript - webpack-dev-server - 浏览器不刷新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35268850/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com