代码之家  ›  专栏  ›  技术社区  ›  Anilkumar Sandeboena

中的错误/src/index.tsx模块构建失败(从./node_modules/ts-loader/index.js):

  •  0
  • Anilkumar Sandeboena  · 技术社区  · 2 年前

    我正在尝试使用webpack将react应用程序构建到bundle.js中,因此我面临这个问题

    const path = require('path');
    
    module.exports = {
        mode: 'development',
         devtool: 'inline-source-map',
        entry: './src/index.tsx', // Entry point of your application
        output: {
            path: path.resolve(__dirname, 'dist'), // Output directory
            filename: 'bundle.js', // Output filename
        },
        module: {
            rules: [
                {
                    test: /\.tsx?$/,
                    use: 'ts-loader',
                    exclude: /node_modules/,
                  },
                {
                    test: /\.css$/, // Add this rule to handle CSS files
                    use: ['style-loader', 'css-loader'],
                },
                {
                    test: /\.svg$/, // Add this rule to handle SVG files
                    use: ['@svgr/webpack'],
                },
                {
                    test: /\.(png|jpe?g|gif)$/i,
                    use: [
                      {
                        loader: 'file-loader',
                      },
                    ],
                  },
                  
            ],
        },
        
        resolve: {
            extensions: ['.ts', '.tsx'],
        },
    };
    

    期望使用webpack构建bundle.js

    enter image description here

    0 回复  |  直到 2 年前