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

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.

Related

Vue static file from public folder ends up in Webpack bundle?

In my VUE webproject I like to read a local JSON.
This JSON should not be included in the webpack bundle.
From the Vue Cli help files:
"Any static assets placed in the public folder will simply be copied and not go through webpack. You need to reference them using absolute paths."
https://cli.vuejs.org/guide/html-and-static-assets.html#the-public-folder
I created the Hello-World application from VUE CLI with VUE 3.
Now when I import a static json from the public folder it does get copied as-is to the destination folder, but it get's included in the webpack bundle as well.
import config from '/public/config.json'
Any help is much appreciated!

how to move static assets of package.json libraries to cdn server from openshift build

I have PHP application and am maintaining my frontend assets using npm (package.json). When I start build in openshift then the build have to import my static libraries into my project assets folder which I defined in package.json and move to CDN server (I have shared network location which I can share with build service account - PVC(Persistence Volume Claim) with ReadWrite access) and deploy my php app to my php container.
spapp
applications - folder
assets - my static assets such css, js, images
composer.json - php libraries
package.json - static libraries
When I request a build then the build will do the following:
install my composer.json libraries (working fine now)
install my package.json libraries into assets folder and move it to CDN server via network path or shared PVC ( Expecting )
deploy my app to PHP container (working fine now)

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.

Exclude json config files in webpack

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?