Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Merge requests
  • !1305

Whitelist files that can be embedded through url-loader

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/pugnascotia/whitelist-url-loader into master Dec 21, 2016
  • Overview 36
  • Commits 11
  • Pipelines 0
  • Changes 7

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

  1. Create a demo app with ./tasks/cra.sh my-app-test
  2. cd my-app-test
  3. Add a 1K PNG, a 50K PNG and a PDF to ./src
  4. 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>
  1. Start dev mode and check that:
    • The small image is embedded
    • The large image is referenced
    • The PDF is referenced
yarn start
  1. Build a production bundle:
yarn run build
  1. 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
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/pugnascotia/whitelist-url-loader