javascript - webpack-dev-server 沒(méi)有做到實(shí)時(shí)刷新,為什么
問(wèn)題描述
npm start 的時(shí)候打開(kāi) http://localhost:8080/ 修改js文件 并沒(méi)有做到實(shí)時(shí)刷新為什么?換了端口還是一樣, 沒(méi)有實(shí)時(shí)刷新 手動(dòng)刷新也沒(méi)有變化
目錄結(jié)構(gòu)

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 // 實(shí)時(shí)刷新 }, 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’
問(wèn)題解答
回答1:publicPath 路徑問(wèn)題,把點(diǎn)去掉/dist,或使用絕對(duì)路徑publicPath: ’http://127.0.0.1:8080/examples/build
回答2:沒(méi)有刷新還是沒(méi)有實(shí)時(shí)刷新?有沒(méi)有啟用nginx反向代理?
相關(guān)文章:
1. python - flask post提交timestamp不能作為參數(shù),這是為什么?2. java - web端百度網(wǎng)盤的一個(gè)操作為什么要分兩次請(qǐng)求服務(wù)器, 有什么好處嗎3. 請(qǐng)問(wèn)一下,這是6.0的嗎?為什么我下載的和老師講的不一樣呢?4. javascript - 求助大問(wèn)題!!!!!這輸出為什么能不一樣5. javascript - 事件中的打印循環(huán)變量的值時(shí),為什么是一個(gè)固定值。6. python - flask里寫完css為什么沒(méi)法實(shí)時(shí)更新?7. javascript - jqeury用字符串拼接的ID選擇器為什么不能使用?8. mysql - 為什么使用Group By對(duì)SQL的索引性能會(huì)有很大的影響9. 為什么我提交數(shù)據(jù)他就刷新了10. python - 為什么我直接用requests爬網(wǎng)頁(yè)可以,但用scrapy不行?

網(wǎng)公網(wǎng)安備