I have few files in diferent folders (for example: tranlations..js, constants..js). I want to remove files from my build, because one customer doesn't need know about another customers, but you can see variables in Source page. So, i need to config build and remove files witch are for another customer, how I can do it by Vite in react app?
I didn't find solution or library that can help me
Related
How do I set up a Create React App to make a single myApp.js and myApp.css file that can be moved where ever I need?
Background:
At my work we have two older websites in need of updating and both have a React app inside the multi page site. The React apps use Create React App. Not my choice of configuration, this is just what I have to work with and I can not change everything.
Currently, when small changes are made to the site we build the bundled a take the final myApp.js and myApp.css files the CRA produce and moved these to the folder where the website expects them to be.
It might be easier to understand it this way. The app builds the .js|.css bundle files here:
../appA/someFolder/build/static/main.js and ../appA/someFolder/build/static/main.css.
These files are then moved to here:
../appA/hostThisSite/someFolder/js/main.js and ../appA/hostThisSite/someFolder/css/main.css
And for the second website it does the same yet moves the file to a whole other website structure
../../appB/hostThisSite/someFolder/js/main.js and ../../appB/hostThisSite/someFolder/css/main.css
Currently we need to update the React app. And to do so I need to address that the new Create React App creates a bunch of files in the /build/static/ folder (and they include hashes in the name and not myApp.js and myApp.css.)
I have done research and the only thing I have come up with is this:
https://www.labnol.org/code/bundle-react-app-single-file-200514
And the boss doesn't want me to use gulp.
This is a known issue in create-react-app, several proposed solutions in https://github.com/facebook/create-react-app/issues/5306 that involve using npm packages such as react-app-rewired or craco.
Another answer to this question with two possible solutions, one with eject another with react-app-rewired https://stackoverflow.com/a/58570278/388038
This is my first time I am working with IPFS together with React.
Judging from the reactjs examples, the code to run the website itself does not different from non-IPFS-based website.
As per documentation of the hosting I use (www.unstoppabledomains.com), in order to be compliant to IPFS, I need to have all files in same directory level.
The command npm run build produces default react directory structure with static folder and its child folders for css, js and media.
Therefore, how to achieve that all files, produced by build target, is in same level (a.k.a there is no folder static and no subfolders)?
There's no requirement for any specific directory setup to use IPFS, you can structure your project however you see fit.
Are you seeing an error message or other problem?
I’m learning about React and plan to use Firebase and Firebase Functions in an app. When I create a React project I am given a package.json file.
If I add Firebase Functions to the project I am given a second package.json file in the functions folder.
Is this advisable or does it create a specific issue?
If two files is ok, where would you add future scripts?
it's completely fine to have multiple package.jsons in a project so long as they aren't at the same level in the directory
your use case sounds like it's correct to use both but just remember to install future packages in the correct one. You should keep the firebase functions one inside /firebase-functions package and then only install firebase function related stuff
in your other directory use this for installing node_modules you will use for your project. and remember you will need to install firebase in this package.json as you'll be using it in this project
again for future scripts, just add them to the relevant directory
I understand that in react you cannot import files outside src folder.
But what is the reason for it exactly and can I disable it?
In my project react web app is only part of the whole thing, and different parts share some files (configs, build output), so folder structure looks like this
ProjectRoot/
config
build-output/
Part1/
Part2/
WebApp/
src/
...
Sure, you can copy files or create symlinks, but that's duplication and inconvenient.
This is a restriction of Create React App only.
This tool exists to get new users up and running with the react framework as fast as possible by abstracting away the tooling. The part of tooling that is limiting you in this instance is their webpack configuration, which is preset to only look for javascript files in your src directory.
That explains the why? but to answer the other half of your question:
how can I disable it?
Is that you would need to eject from Create React App and then modify your webpack config to allow it to search directories other than src/
First - this has nothing to do with react itself.
If you refer to importing javascript modules (for now using module loaders like systemjs, require, etc.) then the answer is:
It depends what directory is being served by web server. If you have set up your web server to serve WebApp/src folder only - then no, browser will not be able to get access to the files outside and so module loaders. If you will serve all ProjectRoot directory - then yes, you can.
If you prepare your web application for deployment using some sort of bundlers (webpack, browserify) - it depends on how you will configure them and instruct to include the required files in the resulting bundle.
I want to build a blog with create-react-app and host it on Github pages.
I want the posts content to be md files I dump on some folder in the repo.
I'm able to render md files currently only by requiring each file in code, fetching it and rendering.
this s not very scalable.. I don't want to have an import line for every file I add...
Is there a way for me to "require" all of the files in a specific folder so I can fetch them in runtime?
Checkout gatsby https://github.com/gatsbyjs/gatsby
You should be able to get an idea how they are pulling this off without a backend service. Gatsby does exactly what you're describing. If anything you should be able to extract the functionality if you don't want to go with the whole framework. It is very very fast though =)