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. javascript - 为什么nodejs运行Date函数显示的时间不准确?2. css - .clearfix:after中为什么设置display: table3. javascript - 请问为什么这个补零函数为什么要放window.onload外面?4. (小白)python 为什么用return会报错啊?5. python - 请问为什么csdn登录后,浏览器控制台reponse返回的是空6. python - 我在使用pip install -r requirements.txt下载时,为什么部分能下载,部分不能下载7. css - 既然移动端viewport可以设置宽度,为什么还要用rem方案?8. html5 - 新手提问:为什么form表单的post请求 路由处理不了9. python - 《flask web开发》中为什么发不出确认邮件?10. 前端 - 为什么html文件一般都不压缩啊?

网公网安备