javascript - webpack-dev-server 没有做到实时刷新,为什么
问题描述
npm start 的时候打开 http://localhost:8080/ 修改js文件 并没有做到实时刷新为什么?换了端口还是一样, 没有实时刷新 手动刷新也没有变化
目录结构

webpack.config.js
const path = require(’path’);const webpack = require('webpack');module.exports = { entry: ’./src/index.js’, output: {path: path.resolve(__dirname, ’dist’),filename: ’foo.bundle.js’,publicPath: ’./dist’ }, module: {rules: [ {test: /.js$/,loader: ’babel-loader’,exclude: /node_modules/ }] }, devServer: {contentBase: './',historyApiFallback: true,hot:true,inline: true // 实时刷新 }, plugins: [new webpack.HotModuleReplacementPlugin() ]};
package.json
{ 'name': 'test', 'version': '1.0.0', 'description': '', 'main': 'index.js', 'scripts': { 'test': 'echo 'Error: no test specified' && exit 1', 'start': 'webpack-dev-server' }, 'author': '', 'license': 'ISC', 'devDependencies': { 'babel-core': '^6.24.1', 'babel-loader': '^7.0.0', 'babel-preset-es2015': '^6.24.1', 'css-loader': '^0.28.0', 'webpack': '^2.4.1', 'webpack-dev-server': '^2.4.4' }}
已解决
//修改//publicPath: ’./dist’ => publicPath: ’/dist’
问题解答
回答1:publicPath 路径问题,把点去掉/dist,或使用绝对路径publicPath: ’http://127.0.0.1:8080/examples/build
回答2:没有刷新还是没有实时刷新?有没有启用nginx反向代理?
相关文章:
1. 编辑管理员信息时,为什么没有修改过的内容会为空?2. java - 向mongoDB中插入数据时,cpu的system time很高是为什么?3. css3 - 为什么没有深入讲解CSS的书?4. 为什么背景图无法正常显示5. python - flask post提交timestamp不能作为参数,这是为什么?6. python2.7为什么点击了"开始"按钮后,tkinter上的按钮,图中红色部分,再也点不动了?7. 计算不显示结果是为什么?8. python的scatter中color为什么不能设置每个点的颜色9. 为什么我跳转不了啊10. python - 使用scrapy的时候,循环为什么只能获取第一页的

网公网安备