You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Whitelist files that can be embedded through url-loader (facebook#1305)
* Whitelist files that can be embedded through url-loader
Change the current catch-all loader to use file-loader instead of
url-loader, and exclude common image file extensons. Add another url-loader
for images, configured identically to the original catch-all loader.
Part of issue facebook#1293.
* Update tests to reflect change in loader config
* Integration test fix
* More CI fixes
* Work around broken loader-utils behaviour in integration tests
* Revise the documentation around file loading
* Documentation tweaks
* Docs tweak
* Update test now that webpack/loader-utils has been updated
* Update react-scripts to depend on babel-loader@7.0.0-alpha.2
* Bump deps
-[Adding Images, Fonts, and Files](#adding-images-fonts-and-files)
27
27
-[Using the `public` Folder](#using-the-public-folder)
28
28
-[Changing the HTML](#changing-the-html)
29
29
-[Adding Assets Outside of the Module System](#adding-assets-outside-of-the-module-system)
@@ -466,11 +466,13 @@ Then we can change `start` and `build` scripts to include the CSS preprocessor c
466
466
467
467
Now running `npm start` and `npm run build` also builds Sass files. Note that `node-sass` seems to have an [issue recognizing newly created files on some systems](https://github.com/sass/node-sass/issues/1891) so you might need to restart the watcher when you create a file until it’s resolved.
468
468
469
-
## Adding Imagesand Fonts
469
+
## Adding Images, Fonts, and Files
470
470
471
471
With Webpack, using static assets like images and fonts works similarly to CSS.
472
472
473
-
You can **`import` an image right in a JavaScript module**. This tells Webpack to include that image in the bundle. Unlike CSS imports, importing an image or a font gives you a string value. This value is the final image path you can reference in your code.
473
+
You can **`import` a file right in a JavaScript module**. This tells Webpack to include that file in the bundle. Unlike CSS imports, importing a file gives you a string value. This value is the final path you can reference in your code, e.g. as the `src` attribute of an image or the `href` of a link to a PDF.
474
+
475
+
To reduce the number of requests to the server, importing images that are less than 10,000 bytes returns a [data URI](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) instead of a path. This applies to the following file extensions: bmp, gif, jpg, jpeg, and png. SVG files are excluded due to [#1153](https://github.com/facebookincubator/create-react-app/issues/1153).
0 commit comments