Craco 无法与 [email protected] 正常工作

2024-01-01

将react-scripts升级到v5后,craco start不能正常工作。应用程序启动时没有错误,但在浏览器中,有一个空白页面,如果我打开检查器,我只能看到 index.html 代码而不是反应代码。它运作良好[电子邮件受保护] /cdn-cgi/l/email-protection。这是我的本地文件;

包.json

{
  "name": "test-app",
  "private": true,
  "version": "0.1.0",
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ],
  "dependencies": {
    ...
    "@babel/preset-react": "^7.16.7",
    ...
    "@craco/craco": "^6.4.3",
    ...
    "babel-loader": "^8.2.3",
    ...
    "react": "^16.11.0",
    "react-dom": "^16.11.0",
    "react-scripts": "^5.0.0",
    "scriptjs": "^2.5.9",
    "single-spa": "^5.9.0",
    "single-spa-react": "^4.6.1",
  },
  "devDependencies": {
    "@babel/core": "7.7.2",
    "@babel/plugin-proposal-class-properties": "^7.12.1",
    "@babel/plugin-proposal-decorators": "^7.17.2",
    "@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.1",
    "@babel/plugin-proposal-optional-chaining": "^7.6.0",
    "@svgr/webpack": "6.2.1",
    "@types/chance": "^1.0.8",
    "@types/jest": "^24.9.0",
    "@types/node": "^16.7.10",
    "@types/react": "^16.9.18",
    "@types/react-dom": "^16.9.5",
    "@types/react-router-dom": "^5.1.3",
    "@types/yargs": "^17.0.2",
    "@typescript-eslint/eslint-plugin": "^4.14.1",
    "@typescript-eslint/parser": "^4.14.1",
    "@webpack-cli/serve": "^1.6.1",
    "compression-webpack-plugin": "^9.2.0",
    "css-loader": "3.2.0",
    "dotenv": "^10.0.0",
    "dotenv-expand": "5.1.0",
    "dotenv-webpack": "^7.1.0",
    "env-path": "^1.0.7",
    "enzyme": "^3.10.0",
    "enzyme-adapter-react-16": "^1.15.1",
    "eslint": "^7.11.0",
    "eslint-config-airbnb": "^18.0.1",
    "eslint-config-airbnb-typescript": "^12.3.1",
    "eslint-config-react-app": "^6.0.0",
    "eslint-config-standard": "^14.1.0",
    "eslint-config-standard-jsx": "^8.1.0",
    "eslint-import-resolver-typescript": "^2.4.0",
    "eslint-loader": "^4.0.2",
    "eslint-plugin-flowtype": "5.2.0",
    "eslint-plugin-import": "^2.20.0",
    "eslint-plugin-jsx-a11y": "^6.2.3",
    "eslint-plugin-promise": "^4.2.1",
    "eslint-plugin-react": "^7.22.0",
    "eslint-plugin-react-hooks": "^4.2.0",
    "eslint-plugin-standard": "^4.0.1",
    "file-loader": "4.2.0",
    "react-app-rewired": "^2.2.1",
    "react-svg-loader": "^3.0.3",
    "react-test-renderer": "^16.11.0",
    "sass-loader": "8.0.0",
    "style-loader": "1.0.0",
    "systemjs-webpack-interop": "^2.3.7",
    "terser-webpack-plugin": "5.3.1",
    "tsconfig-paths-webpack-plugin": "^3.5.1",
    "url-loader": "2.2.0",
    "webpack": "^5.69.1",
    "webpack-cli": "^4.9.2",
    "webpack-manifest-plugin": "4.1.1",
    "workbox-webpack-plugin": "6.4.2",
    "yargs": "^17.1.1"
  },
  "scripts": {
    "version": "node scripts/version.js",
    "solid": "node scripts/solid.js",
    "start": "craco start",
    "build": "craco build"
  },
  "typings": "./src"
}

craco.config.ts

   export default {
      mode: 'development',
      babel: {
        plugins: [['@babel/plugin-proposal-decorators', { legacy: true }]],
      },
      eslint: {
        enable: false,
      },
      webpack: {
        configure: (webpackConfig) => {
          // add this line
          // use System
          webpackConfig.output.libraryTarget = 'system';
          delete webpackConfig.optimization;

          webpackConfig.externals = [
            'react',
            'react-dom',
            'single-spa',
            'react-router',
            'react-router-dom',
            '@mf-experiences',
          ];

          return webpackConfig;
        },
      },
      // Adding Server
      devServer: (devServerConfig) => {
        devServerConfig.proxy = {
          '@mf-experiences': {
            target: 'path...',
            secure: false,
            changeOrigin: true,
          },
        };

        return devServerConfig;
      },
    };

src/index.js

import React from 'react';
import ReactDOM from 'react-dom';
import './styles/nullifier.scss';
import './styles/index.scss';
import './tracking/facebook.ts';
import App from './App';
import * as serviceWorkerRegistration from './serviceWorkerRegistration';

const setRealVh = () => {
  document.documentElement.style.setProperty(
    '--vh',
    `${window.innerHeight * 0.01}px`
  );
};
window.addEventListener('resize', setRealVh);
document.documentElement.style.setProperty('--intensity', `${768 * 0.005}px`);

ReactDOM.render(<App />, document.getElementById('root'));


// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://cra.link/PWA
// serviceWorkerRegistration.register({
//   onUpdate: (registration) => registration.waiting.postMessage({ type: 'SKIP_WAITING' }),
// });
serviceWorkerRegistration.unregister();

它目前作为一个单独的分支提供:

https://github.com/gsoft-inc/craco/tree/support-cra5 https://github.com/gsoft-inc/craco/tree/support-cra5

npm 上也发布了一个版本:

"@craco/craco": "^7.0.0-alpha.3"

但请注意,他们正在寻找维护者:https://github.com/gsoft-inc/craco/issues/415 https://github.com/gsoft-inc/craco/issues/415

编辑:他们找到了维护者https://github.com/dilanx/craco/issues/426 https://github.com/dilanx/craco/issues/426

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Craco 无法与 [email protected] 正常工作 的相关文章

随机推荐

  • 如何删除默认的 CRA React 图标?

    我已经删除了 head 标签中的链接 但图标仍然被渲染 是否可以删除或更改 您的图标位于 project root gt public gt favicon ico 中 public favicon ico 删除它很困难 因为如果浏览器找不
  • 在 GKE 上使用 nginx 入口控制器时负载均衡器的节点不健康

    我已经设置了 nginx 入口控制器如下本指南 https github com kubernetes ingress nginx blob master deploy README md 入口运行良好 我能够访问defaultbacken
  • 找不到 png.h 文件 - Linux

    我正在尝试跑步this http cvlab epfl ch cms site cvlab2 lang en software pom index php在 linux ubuntu 中 当我输入 make 时 它 会说 rgb image
  • 尝试使用 jQuery 隐藏 html 表的列

    function func id document ready function toggle click function td nth child id gt div toggle return false 我试图隐藏与单击的按钮对应的
  • 使用 select、group by 和 count 时如何获得非空结果集?

    这是当前的查询 SELECT status ct reconcile status IFNULL COUNT status ct reconcile status 0 AS sch change status num FROM db cre
  • 我可以使用WebRTC接收标准RTP视频流吗?

    我有两台计算机在同一网络上 其中一个使用 RTP 协议传输电影 H264 是否可以创建一个简单的 JavaScript 应用程序来在第二台计算机上接收此流并显示在视频标签中 到目前为止 我对WebRTC的印象是它被设计为在浏览器之间使用 都
  • 一直运行的 iOS GPS 跟踪应用程序

    我正在尝试制作一个应用程序来始终跟踪用户的 GPS 该应用程序是一种汽车 GPS 跟踪器 用于始终获取驾驶员的位置并将其发送到服务器 我尝试将 位置更新 添加到 后台模式 但进入后台时应用程序将在 10 分钟后自动暂停 有没有办法让这个应用
  • 在另一个单元格中输入数据并按 Enter 选项后转到特定单元格

    我有一个 Excel 工作表 我正在 A2 B2 和 C2 中输入数据 按 Enter 键后 我希望光标选择下一行 以便我可以输入 A3 B3 和 C3 等信息 我找到了这个信息 Private Sub Worksheet Change B
  • 确定点是否在 3D 三角形内部

    我正在寻求对我对确定点是否位于 3D 三角形内部的方法的看法的认可 给定一条 R t e td 形式的射线和一组三个点 T V0 V1 V2 它们在三维空间中形成一个三角形 我知道如何找到该平面的参数方程三点形成以及如何确定射线是否与该平面
  • Android - InstrumentationTestRunner

    我是 Android 新手 并且来自 NET 背景 对 Java 有点生疏 我正在为 Android 上运行的移动应用程序开发一些测试自动化 目前 我只是使用 Android 调试桥通过命令行启动测试 但当我尝试运行任何测试时遇到错误 首先
  • 从 SQL 查询中获取参数名称

    后端是PostgreSQL服务器9 1 我正在尝试构建 AdHoc XML 报告 报告文件将包含 SQL 查询 所有查询都必须以 SELECT 语句开头 SQL 查询将带有参数 根据关联列的数据类型 这些参数将相应地呈现给用户以提供值 一个
  • Traceview最大记录时间?

    我正在使用 Debug startMethodTracing 和 Debug stopMethodTracing 来优化一段需要大约 30 秒执行的代码 但是当我使用跟踪视图打开跟踪文件时 它只显示大约 6 5 秒的跟踪数据 有什么线索吗
  • Java 中的 方法是什么?它可以被覆盖吗? [复制]

    这个问题在这里已经有答案了
  • 陷入 Matlab 的用于匹配 vlfeat 图像点的子图机制

    我正在 Matlab 中做 vlfeat 我正在关注这个问题here https stackoverflow com questions 1500498 how to use sift algorithm to compute how si
  • 获取EAX寄存器的上半部分

    在x86汇编语言中 有没有办法获得上半部分EAX登记 我知道AX寄存器已经包含了下半部分EAX注册 但我还不知道有什么方法可以获得上半部分 我知道mov bx ax会移动下半部分eax into bx 但我想知道如何移动上半部分eax in
  • 参数中的前向声明与“正常”前向声明之间的区别

    模板 参数中的前向声明 使用详细类型说明符 https en cppreference com w cpp language elaborated type specifier 和 正常 的前向声明 void foo struct bar
  • 音视频同步、TS MPEG2;H264/AVC、了解Handbrake中的PTS

    同步一直让我着迷 或者准确地说 为什么媒体播放器可以同步观看 ts 而重新组装的解复用音频 视频却不同步 所以我试图了解这一点 以及可以采取哪些措施来防止这种情况发生 我已阅读以下内容 https trac handbrake fr wik
  • 重用 Azure 服务总线中的连接

    我们在 Windows Azure 上以 Web 角色托管了一个 API 该 API 具有 2 个实例 用于接收请求 验证它们 然后将它们添加到 Azure 服务总线队列 最近我们开始对此进行负载测试 发现我们当前的代码抛出以下异常 无法将
  • Silverlight 工具包;饼图颜色

    我有一个巨大的问题无法解决 假设我有五种不同的水果 我希望每种水果都与某种颜色相关联 假设我有三个 篮子 其中包含零个或多个上述水果 当我为我的三个篮子制作饼图时 每个楔形只是一些随机颜色 大概是由控件选择的 我该怎么说 将图表中的蓝莓 香
  • Craco 无法与 [email protected] 正常工作

    将react scripts升级到v5后 craco start不能正常工作 应用程序启动时没有错误 但在浏览器中 有一个空白页面 如果我打开检查器 我只能看到 index html 代码而不是反应代码 它运作良好 电子邮件受保护 cdn