Add a separate HTML file into create-react-app - javascript

I know react is for Single Page Application. I have already build a complete application. I have a particular 3rd party integration that requires javascript and css files. I cannot add those external scripts as it breaks my entire application by overriding css and js.
I need to have a separate admin.html file which can have its own css and javascript tags. I do not want any conflict with my react app which renders on index.html
I tried to eject create-react-app and add a new admin.html.
https://github.com/facebook/create-react-app/issues/1084#issuecomment-568550609
But it uses only one page(index.html). This will not help me because I need completely a separate html file which I can import any javascript or css freely without any conflict on my index.html
Currently the possibility I thought was to create a separate react application just to render to this admin.html. So that there won't be any conflicts between javascript and css. But I want to know if there is an alternate way that I can achieve it in create-react-app. If so, simple example would be greatly appreciated.
PS: I need to redirect from one of components in my application to this new view admin.html with some data

Related

Is there any way implement CSS file on ReactJS?

The app has two sides, Blog and management.
I code the management part with ant design.
The blog part is with html template. (assets file folder in css, js, img exc.)
While rendering React, all css and js files print on the same page and confusion occurs. Css files are corrupted in design because they overlap.
I use craco as the web configuration, you can find the configuration in the link below.
https://ant.design/docs/react/use-in-typescript
Is there a way to separate two templates with react router dom? For example, can different theme files work on each page?

How do i automatically import JS and scss files when i include a .php component? (not using frameworks)

I am a starting web developer. The company I work for makes relatively simple websites, some with blogs and/or products. We use our own CMS and don’t use a framework.
I am trying to improve the architecture/structure we use for websites. Which is currently done with a single stylesheet and a single JS file. Which is awful to work with for me because I can never find anything in these files.
So I started to separate these files into smaller scss and JS files. I’ve done some research.
And i’d like to work with components Like this (preferably the first one):
I think this would work well for me because i am working in those 3 files at the same time, and then i don’t have to open them from different locations. Is this a good way to structure websites?
When i include the .php file for the component i would like to have it automatically call upon the right JS and scss files. This way i could move the component to a different website include it and it would work.
Is this possible? Is this even the right way to think about it?
And if not how do i go about importing or compiling JS and scss/css?

How do I implement a html/css/js theme into Vue properly?

I got a bootstrap theme that consists of HTML, CSS and Javascript. Now, I want to implement it (or let's say make it functional) in Vue. I have my index.html file that contains the container and it works. Now, my theme does have an index.html file as well. I just thought I can copy the whole file into the Vue-index.html and add the div with the id "app" around the area that changes the content. But it does not work. Basically, Vue does not load any external css or js files even though I reference them correctly (with relative reference using the dot: ./assets/css/style.css). It works inside a .vue-file (i.e. component) but not inside the index.html. What do I do wrong?
Yep, beginner here.
When you put them inside your index.html they are not compiled.
You can read about it HERE
Your index.html is something called a target. Vue uses this file as a mounting point for the rest of the application, so it's kept relatively clean, most likely with just metadata and a DOM mounting point. It works by loading the index.html in the browser and then mounting your Vue application on top of it.
If you're trying to apply some styles to a Vue application/components, your best bet is to modify *.vue files inside the app source of your Vue project (typically, /your-project/src). They will contain snippets of relevant sections/components alongside their logic (JavaScript) and styles (CSS/Sass), provided your project uses Single-File Components format.
For future reference:
It's hard to offer a solution without knowing the structure of your project, what type of components you are using, or even having code samples to get an idea of how things are working inside.
We'd need more information to be able to help you more accurately, so maybe you could create a lightweight demo on an interactive platform like codesandbox.io?

Partial Implementation of create-react-app to a website

I'm currently developing a website/webapp (I don't really know the clear distinction between it) for my school project. Initially I was planning to develop entirely through just HTML/CSS and JS, however, my adviser told me to use react framework for parts of the pages instead of just doing it with Java for the sake of simplicity. This has been really messing me up since I have no background in web development and I'm confused in general.
I currently have all of the HTML pages styled with CSS, and I was able to transition part of the web-app to react using create-react-app. However, I have no clue how to connect these two.
I created the my-app folder inside the main directory which contains most of the HTML folders, but how would I go by to
1. Access the react app from the HTML page?
2. Access the HTML page in the main directory from the react app?
Following is my directory as a reference
mainDir
|_____bunch of html files
|_____css //contains all css files
|_____img // contains all images
|_____my-app
|____all the files created by create-react-app
Approaches I have tried:
- using the in the HTML pages in the main directory to jump to index.html in the my-app file to load the app
- changing the file path on the tag inside the App.js render() function of each class to something like ../../welcome.html which is the relative path to an HTML in the main directory.
Thank you for your help in advance. I'm welcome to any and all suggestions! If there isn't enough information to assess the situation, please let me know!
Checkout
This Example source code, from React.js: "Add React in One Minute" guide.
What is it?
It's a super bare-minimum implementation of React using:
1 x .html file
1 x .js file
Given your current setup, I'd say it's a lot simpler than trying to incorporate create-react-app.
Let me know if this helps; I'm happy to delete this if it's not useful.

How to load script files dynamically with react and gulp

I'm developing a gaming platform and I've chosen react as the technology on the frontend. Currently I'm building all the script files into one js file using gulp. That doesn't cause a problem, because there's only one game, but when the number of games increases, the browser will load a lot of useless code. So I'd like to have all the platform logic in a single file, and the script for each game would be built into separate files which would be loaded on the browser when they are needed. How could I reference a react class within a built and dynamically loaded file?
For example, game1 consists of 3 files, which are built into game1.js. The main file of those 3 contains a react class Game1. How would I reference that class? Normally if those were in the same bundle, I would write "var game = require('game1_main')".
If webpack is an option for you, you could use its codesplitting feature.

Categories

Resources