From ea12afbd5615e01f73ccdfdb17fa7b9d50d55f2a Mon Sep 17 00:00:00 2001 From: sgabenza Date: Wed, 6 Mar 2019 11:58:56 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=93=20=F0=9F=91=8D=20update=20public?= =?UTF-8?q?=20folder=20F.A.Q.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0e3d4a94..437d3374 100644 --- a/README.md +++ b/README.md @@ -366,9 +366,16 @@ You can put them in the `src/fonts` folder and require them from the CSS like th You usually put the assets you require from the `index.html` here. Like for example the favicon. -You should try as much as possible to require the .css and .js file from the `src` folder, so they are bundled and optimized. For example if you need a service worker file just for making the app work offline, use the [offline-plugin](https://github.com/NekR/offline-plugin). An alternative is the [workbox-webpack-plugin](https://developers.google.com/web/tools/workbox/modules/workbox-webpack-plugin). +If you need a service worker file just for making the app work offline, use the [offline-plugin](https://github.com/NekR/offline-plugin). An alternative is the [workbox-webpack-plugin](https://developers.google.com/web/tools/workbox/modules/workbox-webpack-plugin). + +You should normally import stylesheets, images and fonts in JavaScript files using the Module System because this mechanism provides a number of benefits. + +The `public` folder is a useful workaround that gives you access from browsers to a file, outside the Module System. If you put a file into the public folder, it will not be processed by Webpack. Instead it will be copied into the build folder untouched. + +Be careful because with this approach files are not post-processed or minified and first of all, if lost, they will cause 404 errors. + +For technical in-depth analysis read the create-react-app [documentation].(https://facebook.github.io/create-react-app/docs/using-the-public-folder) -You should also try as much as possible to avoid putting images in the `public` folder, because missing images would cause 404 errors for the users instead of compilation errors.