Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 反应:为多个html文件在config-overrides.js文件中添加多个入口点_Reactjs_Webpack_Create React App_Antd - Fatal编程技术网

Reactjs 反应:为多个html文件在config-overrides.js文件中添加多个入口点

Reactjs 反应:为多个html文件在config-overrides.js文件中添加多个入口点,reactjs,webpack,create-react-app,antd,Reactjs,Webpack,Create React App,Antd,我对CRA(它是根据ant design description for project setup中的文档重新布线的)有所反应,并且在webpack配置文件中添加多个入口点时面临问题 我在公用文件夹中有两个html文件,index.html和stack.html -public -index.html //runs on localhost:3000 -stack.html // runs on localhost:3000/stack.html -src -index.t

我对CRA(它是根据ant design description for project setup中的文档重新布线的)有所反应,并且在webpack配置文件中添加多个入口点时面临问题

我在公用文件夹中有两个html文件,index.html和stack.html

-public
  -index.html   //runs on localhost:3000
  -stack.html   // runs on localhost:3000/stack.html
-src
  -index.tsx
  -stack.tsx
-config-overrides.ts
默认的html index.html和index.tsx用于引导和加载react组件

我创建了stack.html文件,并相应地创建了stack.tsx文件作为启动和加载react组件的入口点。我无法把事情联系起来。
应该进行什么配置才能将其连接起来。

好的,没有好的方法可以做到这一点。 一种方法是只使用react脚本,通过复制和替换每个构建的index.html和index.js来构建多个应用程序。差不多


同样对于CRA v3,有一个开放的PR用于修复此问题:

可以这样做,但您需要从CRA中弹出。之后:

  • 将条目添加到
    path.js
    中的其他html文件中
  • webpack.config.js
    中更新
    entry
    ,并添加第二个html文件条目(类似于原始的
    entry
  • webpack.config.js
    中更改输出文件名。将
    static/j/bundle.js
    更改为
    static/js/[name].bundle.js
  • Upadte webpack插件使用注入的JS脚本生成第二个文件(也在
    webpack.config.JS
    中)
  • 更新
    ManifestPlugin
    配置以包含新的入口点(也在
    webpack.config.js
    中)
  • 最后,开发和生产有两个不同的步骤

  • 对于开发人员,请使用
    webpackDevServer.config.js
    中的以下命令重写路径(如果要将所有
    /admin
    重定向到
    admin.html
    文件):
  • 对于生产,此步骤对于每个提供程序都是不同的。对于Heroku来说,非常简单,只需创建一个包含以下内容的
    static.json
    文件:
  • {
    “root”:“build/”,
    “路线”:{
    “/admin**”:“admin.html”,
    “/**”:“index.html”
    }
    }
    
    有关完整详细信息和文件差异,请参阅

    verbose: true, 
    rewrites: [
      { from: /^/admin/, to: '/admin.html' },
    ],