Webpack 本地主机网页包显示';s文件目录?
当我运行webpack dev server时,它会给我如下的localhost链接Webpack 本地主机网页包显示';s文件目录?,webpack,Webpack,当我运行webpack dev server时,它会给我如下的localhost链接http://localhost:8080/当我输入时,会得到如下图所示的文件目录 只有单击我的html目录(在我的例子中是build文件夹),我才能重定向我的index.html页面 如果我从build中删除我的index.html以使其正常工作,但我需要此目录分发,因为当前项目中将有几个html文件 我的网页版本 "webpack": "^4.8.3" 我怎样才能解决这个问题请帮忙 Mywebpack.c
http://localhost:8080/
当我输入时,会得到如下图所示的文件目录
只有单击我的html
目录(在我的例子中是build文件夹),我才能重定向我的index.html
页面
如果我从build中删除我的index.html
以使其正常工作,但我需要此目录分发,因为当前项目中将有几个html
文件
我的网页版本
"webpack": "^4.8.3"
我怎样才能解决这个问题请帮忙
Mywebpack.config.js
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const webpack = require('webpack');
let conf = {
entry:{
index: "./src/main/index.js"
},
output: {
path: path.resolve(__dirname, "./dist"),
filename:"[name]bundle.js",
publicPath:"dist/"
},
devServer: {
overlay:true
},
module: {
rules: [
{
test: /\.js/,
loader:"babel-loader",
//exclude: "/node_modules/"
},
{
test:/\.scss$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: [
{
loader: 'css-loader',
options: {
// If you are having trouble with urls not resolving add this setting.
// See https://github.com/webpack-contrib/css-loader#url
url: false,
minimize: true,
sourceMap: true
}
},
{
loader: 'sass-loader',
options: {
sourceMap: true
}
}
]
})
}
]
},
plugins: [
new ExtractTextPlugin({
filename:"[name].css"
}),
new HtmlWebpackPlugin({
filename:"index.html",
template:"build/index.html",
hash:true,
chunks:["index"]
}),
new webpack.ProvidePlugin({
'$': "jquery",
'jQuery': "jquery",
'Popper': 'popper.js',
"Bootstrap":"bootstrap.js"
})
]
};
module.exports = (env, options) => {
let production = options.mode === "production";
conf.devtool = production ? false : "eval-sourcemap";
return conf;
}
通过将此配置添加到mydevServer解决了问题
devServer: {
overlay:true,
contentBase: "./build",
hot: true
},