Remove icons and non required fonts


#1

I am trying to do a bit of a tidy up and remove files I do not use. I have been following (without success!)

Basically his advice is to remove the icons and non required fonts from src/theme/variables.scss which I have followed (see below) both icons and noto-sans fonts commented out.

// Ionicons
// --------------------------------------------------
// The premium icon font for Ionic. For more info, please see:
// http://ionicframework.com/docs/v2/ionicons/

// @import “ionic.ionicons”;

// Fonts
// --------------------------------------------------

@import “roboto”;
// @import “noto-sans”;

However when I preform a release build and look at the output file - the icons and fonts are still in the assets folder.

Has anyone got any suggestions?


#2

Ionic v4 does this automatically - one of the features I find most exciting. It only imports what you explicitly ask for. So you might want to try running your app under v4 and see if it works.


#3

Thanks - but V4 is not yet ready for production (or at least that is my understanding) - I have been waiting and waiting for version 4 - must be over 4 months now!


#4

Take a look at: https://github.com/ionic-team/ionic-app-scripts#all-available-tasks

And, create your own copy.config.js:

module.exports = {
  copyAssets: {
    src: ['{{SRC}}/assets/**/*'],
    dest: '{{WWW}}/assets'
  },
  copyIndexContent: {
    src: ['{{SRC}}/index.html', '{{SRC}}/manifest.json'],
    dest: '{{WWW}}'
  },
  copyFonts: {
    src: ['{{ROOT}}/node_modules/ionic-angular/fonts/noto-sans**',
          '{{ROOT}}/node_modules/ionic-angular/fonts/roboto**'],
    dest: '{{WWW}}/assets/fonts'
  },
  copyPolyfills: {
    src: [`{{ROOT}}/node_modules/ionic-angular/polyfills/${process.env.IONIC_POLYFILL_FILE_NAME}`],
    dest: '{{BUILD}}'
  },
  copySwToolbox: {
    src: ['{{ROOT}}/node_modules/sw-toolbox/sw-toolbox.js'],
    dest: '{{BUILD}}'
  }
};

See: https://robferguson.org/blog/2018/04/17/optimising-the-performance-of-an-ionic-pwa-part-2/


How to ignore assets file on build
#5

THanks @robinyo I will work through instructions later today and see what effect it has.