The*_* I. 2 node.js reactjs webpack
我用以下文件夹结构创建了一个React应用
-public
--dist
--- bundle.js
--- styles.css的
--index.html
--images
-server
--server.js
-src
--components
--app.js
-.babelrc
-package.json
- webpack.config.js
我想将其上传到cPanel。那可能吗?我还需要上传node_modules /文件夹吗?
这是我的仓库的链接:https : //github.com/theoiorga/react-expensify-app
Sum*_*aha 28
第 1 步:"homepage": ".",--> 在 package.json 文件中添加这个
第 2 步:npm run build --> 这将创建一个构建文件夹。
第 3 步:制作一个 .htaccess,它看起来像这样
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
</IfModule>
Run Code Online (Sandbox Code Playgroud)
第 4 步:现在将 build 文件夹中的所有文件以及您的 htaccess 放入所需的域或子域中
小智 5
请按照以下步骤在CPanel上部署React网站
Step(1) : in ur project i mean in your local project run this command "npm
run build" then "Build" folder will create automatically after
that
Step (2) : Go to ur project folder in that build folder will appear
Step (3) : Go to inside the "Build" folder and select all files and compress
or make a Zip then upload in cpanel it will work
Run Code Online (Sandbox Code Playgroud)
注意:对于react app,不需要上传整个项目,我们只需要部署build zip文件夹。
希望每个人都能解决您的问题。
在 Cpanel/Server 上部署 React App。请按照步骤
Step 1)转到 Package.json 文件并添加此属性"homepage":"http://yourdomain.com"并将您的域粘贴到其中。喜欢
Step 2) 现在使用构建应用程序 npm run build
在您的项目目录中,它将创建一个构建文件夹,它将包含您项目的所有静态文件。压缩所有文件并上传到您的网站运行所在的 cpanel 目录中。
Step 3)创建一个 .htaccess 文件并将其放在根目录中。并将以下代码粘贴到 .htaccess 文件中。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
</IfModule>
Run Code Online (Sandbox Code Playgroud)
现在运行你的项目。它会工作。
谢谢
| 归档时间: |
|
| 查看次数: |
10807 次 |
| 最近记录: |