Configuration JSON file not found after build react application - reactjs

I have a react application which is relying on a configuration json file for its execution. Plan is to update the JSON file after build for different environment. Never tried before.
So I imported my JSON file like this
import data from './config.json'
So I was able to use the json properties in my application TS file while debugging from VS.
But I tried to build the app, but I cant find that file in any of the build path.
What I did wrong? Or how can I achieve above requirement.
Ultimately I need to update my JSON file while deploying into different environments which is I am trying to achieve.

During the build process your .json file will be incorporated into the .js files. I don't know many details about this, but I believe that it is not possible to do what you want.
What might help you is the use of environment variables. But it will still be necessary specific builds for each environment.

Related

How to find all the react compiled files?

I am now working on a react ecommerce website and I have encountered an issue that I forgot to give keys to the lists I rendered. So, I was wondering if there is a way to see one file which contains all the code for that web app, like in Sass , we write code in different files but we are able to see the massive file that contains all the code that we wrote across multiple files.Even if we can't change that file, it would be nice to see how many lines of code are there. So ,is there a way to do that?

Instantiating an Imported locally stored .obj File

As you may have understood from the title of my question, I am trying to Instantiate a .obj file that is locally stored on the device with an already given path.
I have already tried to load it as an assetBundle using the WWW method, but it didn't work. I asked a question before on this forum (see here: How To Load A Local File as an AssetBundle with WWW), but I thought that maybe I was going completely in the wrong direction to do this, maybe there is another way to do it. Some people responded that I needed to build the asset before Instantiating it but I didn't understand.
I was hoping for any suggestions on how to do this
Than you in advance :)
For more information, please see other question: How To Load A Local File as an AssetBundle with WWW
Related serialization data is generated when the asset is imported into Unity. And Unity needs these serialization information when managing these assets, so you can import the obj file into the Unity editor, create an assetbundle, and then load it through the associated api.
You can refer to this document:
https://docs.unity3d.com/Manual/AssetBundlesIntro.html

Webpack dev server refresh loop madness

I've been using my own hand-rolled solution (outside of Webpack) for taking a folder of SVG files, extracting out the contents between <svg></svg>, building a JSON file, and then using that to inject into a React component so I can output specific icons with more control over the surrounding attributes.
I came across https://github.com/gilesa/svg-to-json-webpack-plugin which actually does a lot of the same for me, which is awesome! Something odd happened though when attempting to use it with create-react-app and what I suspect is the Webpack dev server. Whenever I attempt to import the generated .json file, the dev server continually refreshes in the browser.
I go into detail a bit more in the issue I created https://github.com/gilesa/svg-to-json-webpack-plugin/issues/1 but my attempts at debugging exactly what's causing the infinite loop haven't been successful. The Webpack plugin API is pretty great, so I've learned a bit along the way, but no dice thusfar.
Ideally, I'd want Webpack to ignore that specific file if that is what's causing the watcher to kick-off again. Potentially because it's creating a file in the same src directory it is looking for changes to? Thanks for any help in the right direction!
this sounds like a known issuse of #25, try this webpack plugin webpack-mild-compile, it should works.

Dart: Accessing a resource out side the project|web/ directory

I have a web-app(browser based) which needs to access a folder full of icons that resides outside the web folder.
This folder MUST be outside the web folder, and would ideally exist outside the project folder all together
however, when specifying the path to the folder neither "../" or making use of a symlink will work
when the page attempts to load the image I always get
"[web] GET /Project|web/icons/img.png => Could not find asset Project|web/icons/img.png."
however I set the image source to "../icons/img.png"
how can i get dart to access this file properly
PS: I attempted a symlink to another part of the filesystem (where the images would be kept ideally) however this did not work either.
The web server integrated into DartEditor or pub serve only serves directories that are added as folders to the files view. When you add the folder to DartEditor you should be able to access the files. This is just for development.
You have also to find a solution for when you deploy your server app. It would be a hazardous security issue when you could access files outside the project directory. Where should the server draw the line? If this would be possible your entire server would be accessible to the world.
Like #Robert asked, I also have a hard time imaging why the files must not be in the project folder.
If you want to reuse the icons/images between different projects you could create a resource package that contains only those images and add them as a dependency to your project.
If you want a better answer you need to provide more information about your requirements.
If you wrote your own server (by using the HttpServer class) it may be possible to use the VirtualDirectory to server your external files.
Looking at look the dartiverse_search example may give you some ideas.
You could put them in the lib directory and refer to them via /packages/Project/...
Or in another package, in which case they would be in a different place in the file system. But as other people have said, your requirement seems odd.

Best practices to store and access resource files in java web application

I have a bunch of text, xml and other files (i.e. resources) that I need to access using servlets in java web app. For example, there is an xml file, a part of which is returned with a servlet by a user query. I am using Tomcat. What is the best practice to store these files and access them from java code?
1) What are the default folders where should I put them, do I need to put them into Web archive or into one of the Jars?
2) How to access the files from java code? How can I set the path to them so it will work in any environment?
P.S. I've read a number of posts related to this topic, most of which recommend to store resources in jars and access them using java.lang.Class.getResourceAsStream(String). It seems strange because classes and data should be separated.
It's perfectly fine to load static resources using the classloader. That's what ResourceBundle does to load the internationalized properties files for example.
Put them in WEB-INF/classes along with your class files, or in a jar inside WEB-INF/lib, and load them with the ClassLoader as indicated by the answers you already read.
That doesn't forbid you to place these files in a separate directory from the Java source files in your project. The build process should just make sure to put them in the appropriate location for runtime. The Maven and Gradle convention is to put the source files under src/main/java and the resource files under src/main/resources.

Resources