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
我无法获得我遗漏的内容?我错过了什么?我错过了什么?我错过了什么?我错过了什么?
答案 0 :(得分:0)
因为您指定了公共路径/ dist /您的应用正在http://localhost:9000/dist/投放。如果您希望从根目录提供它,请删除输出中的公共路径属性。