首页 > 解决方案 > babel-loader 错误 意外的令牌,应为“/<=/>=”

问题描述

与预设错误不同。我收到结束标签的错误。

我无法创建构建

我不得不使用“@babel/plugin-transform-typescript”来解决现有问题。我在哪里使用错误

{ customer_name, avatar, customerUUID }: row

作为函数参数

控制台错误 bable.config 文件

module.exports = {
    presets: ["@babel/preset-env", "@babel/preset-react"],
    plugins: [
        "@babel/plugin-proposal-class-properties",
        "@babel/plugin-proposal-object-rest-spread",
        "@babel/plugin-transform-destructuring",
        "@babel/plugin-transform-typescript",
        "@babel/plugin-transform-react-inline-elements",
        // "@babel/plugin-proposal-export-default-from",
        // "@babel/plugin-proposal-optional-chaining",
        // "@babel/plugin-syntax-dynamic-import",
        // "@babel/plugin-transform-regenerator",
        // "@babel/plugin-transform-runtime",
    ],
};

这是我的 webpack.config 文件

const path = require("path");
module.exports = {
    entry: path.resolve(__dirname, "./src/index.js"),
    module: {
        rules: [{
        test: /\.js$/,
        exclude: /node_modules/,
                use: "babel-loader",
      },
      {
        test: /\.css$/,
        use: ["style-loader", "css-loader"]
      },
      {
        test: /\.svg$/,
        loader: 'svg-inline-loader'
      },
      {
        test: /\.(png|jpe?g|gif)$/i,
        use: [
          {
            loader: 'file-loader',
          },
        ],
      },
        ],
    },
    output: {
        filename: "bundle.js",
    },
};

标签: javascriptreactjswebpackbabel-loader

解决方案


推荐阅读