不是来自webpack的内容是从/ dist提供的

webpack.config.js

var HtmlWebpackPlugin = require('html-webpack-plugin'); const path = require('path'); module.exports = { entry:'./src/app.js', output:{ path:path.join(__dirname, 'dist'), filename:'app.bundle.js', publicPath:'/dist/' }, , devServer: { contentBase: path.join(__dirname, "dist"), compress: true, stats: "errors-only", openPage: '', port:9000, open:true }, plugins: [new HtmlWebpackPlugin({ title:'Forum', filename:'index.html' //template:'./src/app.html' })] } 

我的项目结构:

  ├── forum │ └── dist └── app.bundle.js ├── src │ ├── app.html │ ├── app.js ├── package.json ├── webpack.config.js 

的package.json

  "scripts": { "dev": "webpack-dev-server -d " } 

 Node: v8.3.0 webpack :3.5.4 webpack-dev-server: 2.7.1 

当我运行我的命令npm run dev

输出:

 Project is running at http://localhost:9000/ webpack output is served from /dist/ Content not from webpack is served from /Users/me/Documents/forum/forum 

我无法获取我错过的内容? 我错过了什么? 我错过了什么? 我错过了什么? 我错过了什么?

因为您指定了公共path/ dist /您的应用程序正在http:// localhost:9000 / dist /中提供服务 。 如果您希望从根目录提供它,请删除输出中的公共path属性。