Reactjs 反应:为多个html文件在config-overrides.js文件中添加多个入口点
我对CRA(它是根据ant design description for project setup中的文档重新布线的)有所反应,并且在webpack配置文件中添加多个入口点时面临问题 我在公用文件夹中有两个html文件,index.html和stack.htmlReactjs 反应:为多个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
-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
webpack.config.JS
中)ManifestPlugin
配置以包含新的入口点(也在webpack.config.js
中)webpackDevServer.config.js
中的以下命令重写路径(如果要将所有/admin
重定向到admin.html
文件):static.json
文件:{
“root”:“build/”,
“路线”:{
“/admin**”:“admin.html”,
“/**”:“index.html”
}
}
有关完整详细信息和文件差异,请参阅
verbose: true,
rewrites: [
{ from: /^/admin/, to: '/admin.html' },
],