首页 > 解决方案 > 使用 Webpack 运行我的 React 应用程序的问题

问题描述

这段代码是我的 webpack.config.js 文件。

const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");

module.exports = {
    entry: "./src/index.js",
    output: {
        path: path.join(__dirname, "./dist"),
        publicPath: '/dist/',
        filename: "index_bundle.js"
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                use: {
                    loader: "babel-loader"
                },
            },
            {
                test: /\.css$/,
                use: ["style-loader", "css-loader"]
            }
        ]
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: "./src/index.html"
        })
    ],
    devServer: {
        publicPath: '/dist/'
    }
};

我'

附件是我的错误信息。

我尝试重新安装一些软件包并从 starterkit 修改此配置文件,但无济于事。

提前致谢!

标签: javascripthtmlreactjswebpackes6-promise

解决方案


推荐阅读