简体   繁体   中英

Trying to add the custom HTML and JS code in react application in production

As in many SaaS application we provide admins to add custom HTML, CSS and JS directly from any backend form. It works perfectly in applications built without any JS framework like react or vue.

I want to do the same with react application. The solution that I am thinking can be-

  1. Add the custom code to bundle.js after compiling. We can use gulp or webpack to compile the code or something to apply those changes to the production build of react application.
  2. Is it possible to add the code in the public/index.js directly when the code is in production

I may be wrong. Please suggest me any possible way to make things in production react application.

I really can't say anything about q1 . But for q2 it is not a good option to add code in index.js file even if it runs locally. It is not a good practice to write all your code in index.js or App.js . Trying to make components and write cleaner code is the beauty of React .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM