在 React 应用程序中集成 cortex-js/计算机的问题

发布于 2025-01-16 21:25:49 字数 1580 浏览 0 评论 0原文

我正在尝试使用 cortexjs 提供的计算机。 https://cortexjs.io/compute-engine

我使用保存了此依赖项 npm i @cortex-js/compute-engine

运行 npm start 后,出现以下错误: ./node_modules/@cortex-js/compute-engine/dist/compute-engine.min.js 2:1360 中出现错误 模块解析失败:意外的标记 (2:1360) 您可能需要一个适当的加载器来处理此文件类型。

以下是我的 webpack 文件:

var webpack = require('webpack');
const HtmlWebPackPlugin = require("html-webpack-plugin");
var path = require('path');

module.exports = {
  // output: {
  //   path: path.resolve(__dirname, 'dist'),
  //   filename: 'main.js',
  //   publicPath: '/'
  // },
  mode : 'production',
  devServer: {
    historyApiFallback: true,
  },
  devtool: "source-map",
  module: {
    rules: [
      {
       test: /\.(png|jpg|woff|woff2|gif)$/i,
       use: [
         {
           loader: 'url-loader',
           options: {
             limit: 8192
           }
         }
       ]
     },
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: "babel-loader"
        }
      },
      {
        test: /\.html$/,
        use: [
          {
            loader: "html-loader"
          }
        ]
      },
      {
  test: /\.css$/,
  loader: 'style-loader'
},
{
      test: /\.css$/,
      loader: 'css-loader',
      options: {
        import: true,
      },
    }
    ]
  },
  plugins: [
    new HtmlWebPackPlugin({
      template: "./src/index.html",
      filename: "./index.html"
    })
  ]
};

请有人建议我应该将哪个加载器添加到 webpack.config 文件中才能完成此工作。

I am trying to use compute machine provided by the cortexjs. https://cortexjs.io/compute-engine

I saved this dependency using
npm i @cortex-js/compute-engine

After I ran npm start, I am getting this error:
ERROR in ./node_modules/@cortex-js/compute-engine/dist/compute-engine.min.js 2:1360
Module parse failed: Unexpected token (2:1360)
You may need an appropriate loader to handle this file type.

Following is my webpack file:

var webpack = require('webpack');
const HtmlWebPackPlugin = require("html-webpack-plugin");
var path = require('path');

module.exports = {
  // output: {
  //   path: path.resolve(__dirname, 'dist'),
  //   filename: 'main.js',
  //   publicPath: '/'
  // },
  mode : 'production',
  devServer: {
    historyApiFallback: true,
  },
  devtool: "source-map",
  module: {
    rules: [
      {
       test: /\.(png|jpg|woff|woff2|gif)$/i,
       use: [
         {
           loader: 'url-loader',
           options: {
             limit: 8192
           }
         }
       ]
     },
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: "babel-loader"
        }
      },
      {
        test: /\.html$/,
        use: [
          {
            loader: "html-loader"
          }
        ]
      },
      {
  test: /\.css$/,
  loader: 'style-loader'
},
{
      test: /\.css$/,
      loader: 'css-loader',
      options: {
        import: true,
      },
    }
    ]
  },
  plugins: [
    new HtmlWebPackPlugin({
      template: "./src/index.html",
      filename: "./index.html"
    })
  ]
};

Please can someone suggest which loader should I add to webpack.config file to make this work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文