Created by: pugnascotia
Change the current catch-all loader to use file-loader
instead of url-loader
, and exclude common image file extensions. Add another url-loader
for images, configured identically to the original catch-all loader.
Part of issue #1293 (closed).
Testing
- Create a demo app with
./tasks/cra.sh my-app-test
cd my-app-test
- Add a 1K PNG, a 50K PNG and a PDF to
./src
- Import each resource into
App.js
and include them in the page
import smallPicture from './small.png';
import largePicture from './large.png';
import someDoc from './someDoc.pdf';
// ...
<p><img src={smallPicture} alt="small" /></p>
<p><img src={largePicture} alt="large" /></p>
<p><a href={someDoc}>Here's a PDF</a></p>
- Start dev mode and check that:
- The small image is embedded
- The large image is referenced
- The PDF is referenced
yarn start
- Build a production bundle:
yarn run build
- Check that the production build works as expected by serving it and browsing http://localhost/
docker run -it --rm -v $PWD/build:/usr/share/nginx/html -p 80:80 nginx:alpine