Exclude json config files in webpack - json

I am working on an Electron app that have a few config files that I do require on in the app. The problem is that when webpack my app all the config files are bundled into the bundle.js file but I would like the files to still be accessible to the user without hacking in the bundle.js file. Is there a way to exclude these files in webpack but still do a require on them?

Related

Ionic and Capacitor: How can i change the capacitor.config.ts file to a capacitor.config.json file?

I created an Angular/Ionic project with capacitor. Now I wanted to make changes in my capacitor.config.json but this file is missing? Instead there is the capacitor.config.ts?!
I need the JSON File because otherwise a specific plugin doesnt work!
Here are pictures of my directory and my package.json:
Directory and Files
package.json file
Capacitor 3 allows to have .json, .js or .ts config file.
npx cap init command will create a .ts file if typescript is installed
If you don’t want a .ts file you can just remove it and create a .json file, but everything should still work no matter what the config file extension is.
The version I'm using has the file you require.
application files
ionic version
Please try out ionic 6.18.1 version if possible.

Moving local json/text file to public folder while building with webpack

I have two files sampleJson.json/sampleText.txt in the src folder (src -> data -> sampleJson.json/sampleText.txt).
I am going to copy these files in public while webpack is building app in both dev and prod mode. I am using ejected create-react-app react v16.6 and webpack 4.19. What should I change in webpack config to acheive this goal.

How to add package.json file to built react app?

If use npm build command to build a react app for production environment, we can get a build named folder. There are html, css and JavaScript in it, but the package.json file doesn’t exists.
If we use this file to set http proxy endpoint to connect API, we can’t run the app well because the endpoint can’t be found.
How to deal with this json file rightly in this case?
First if you have package.json of some Node-React application you can run in example windows CMD (terminal console) and make some folder there you put this package.json and navigate to this folder and then, there typing npm install. On this away you can prepare all what is need for this Node-React app. Exactly with this command starting make node_modules folder there stat install need package. Next step is make folders: src and public, there you put next file :
on Src folder App.js, index.js, App.css
on public folder index.html.
That is because in this package.json exists all what is need for starting application, but if you menually build package.json this can make with run npm.
init in CMD.
Use Proxy in package.json file you can use for example if you send some data in case client-server app. There you have in client for HTTP request axios, on server side express. In package.json file add row "proxy":"http://localhost:3001"
from server. For that plz. look How to set port for express server dynamically?

which files are the ones I should upload to a host

I learned to do a working environment based bower, from there install yoeman and gulp and materialize, I made a web page to root of all this, now I want to upload a host (like 000webhost or firebase) but I do not know which files are the ones I should upload
thx
You should upload everything except bower_components directory since it's content is used only when you compile down the things using gulp on your local machine. Once all your source files are piped through gulp, they are not required on the destination location. None of those files is or should be used during a http request.
I don't know exactly what is your project's structure, but because you specified what you use (bower, gulp) then I can deduct.
So after gulp finishes it's work, you have a public directory where all your combined, minified and copied assets live. This is obviously needed on the server, in your markup, you should refer to those files, not the ones fetched by bower when you've done bower install library1 --save. bower install library2 --save.

How to build Angular2 app with external json file using angular-cli in prod mode?

My Angular2 app is using ng2-translate module and 'en.json' file contains translation.
This is all working well in dev mode when built end deployed with angular-cli.
But when built in prod mode, and deployed to WildFly, en.json is not found and translation is not loaded.
How to build app in prod mode, so en.json is packed inside dist directory?
Yes, this issue is related to the webpack configuration employed by angular-cli. In the current state the ng build command keeps content of src/assets directory in the dist directory.
So you can put your files needed to the src/assets - they should be present in a dist build.