2

Angular 7 app uses flag-icon-css.

ng build --prod creates dist directory that contains all flag icon images, even though I use only 5-7 images for now ( I will use more when the app grows ).

This adds a lot of unnecessary weight to the project.

On flag-icon-css github page there are instructions on how to remove unused images by editing flag-icon-list.less, but that didn't do the trick. https://github.com/lipis/flag-icon-css#development

Is there a way to exclude unused flag icon images from the dist directory?

zeljko_a
  • 3,725
  • 1
  • 22
  • 23

1 Answers1

0

I imported flag icons in styles.css from node_modules:

@import 'flag-icon-css/css/flag-icon.css'

Instead of importing from node_modules, I moved flag-icon.css to src/assets/css:

@import 'flag-icon-css/css/flag-icon.css';

Commented out unused icons. Run build again, dist directory will contain only images that are used.

zeljko_a
  • 3,725
  • 1
  • 22
  • 23