如何使用自己的webpack.config调试我的React应用程序?

时间:2019-08-20 15:43:08

标签: reactjs webpack babel

我已经构建了没有create-react-app的react应用,但是我无法调试它。当我尝试时,我看到了我的js代码的精简版。

webpack.config.js

const path = require('path');
const HtmlWebpackPlagin = require('html-webpack-plugin');


module.exports = {
    entry: ['babel-polyfill', './src/index.js'],
    mode:'development',
    output: {
        path: path.resolve(__dirname, 'build'),
        filename: 'index_bundle.js'
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                use: {
                    loader: 'babel-loader'
                }
            },
            {
                test: /\.css$/i,
                use: ['style-loader', 'css-loader'],
            }
        ]
    },
    plugins: [
        new HtmlWebpackPlagin({ template: './src/index.html' })
    ]
}

.babelrc

{
    "presets": ["@babel/preset-env", "@babel/preset-react"]
}```

0 个答案:

没有答案