Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build: Use file-loader to load flag SVG (#26555)
Use webpack's `file-loader` to copy flag SVG assets to `public/images` when it encounters code that `require()`s them. This allows us to drop the unconditional copying we previously did through `CopyWebpackPlugin`, and the code that disabled it for the SDK. Henceforth, webpack will be able to determine on its own whether to include flags SVGs when bundling, depending on whether there's a `require()` that calls for them. Note we're now copying to `public/images/` rather than `public/images/flags/`, since the `file-loader` is generic enough and agnostic of flags to be able to copy any kind of asset whose extension we whitelist -- currently that's only `.svg`, but doesn't mean it's always going to be just flags. In order not to break tests (or have them unduly depend on webpack loaders), we're also adding a Jest helper that essentially translates `require( 'path/to/some.svg' )` to `'some.svg'` (see https://jestjs.io/docs/en/webpack#handling-static-assets).
- Loading branch information
Showing
15 changed files
with
279 additions
and
246 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.