Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Webpack 本地主机网页包显示';s文件目录?_Webpack - Fatal编程技术网

Webpack 本地主机网页包显示';s文件目录?

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

当我运行webpack dev server时,它会给我如下的localhost链接
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
    },