From 39e8dd398ba5e3ff3142be24c1a9b25739f2b39b Mon Sep 17 00:00:00 2001 From: Florent Chehab Date: Sun, 19 Apr 2020 17:42:26 +0200 Subject: [PATCH] fix(bundle size): include only required icons --- package-lock.json | 44 +++++++++++++++++++++++++++++++++++---- package.json | 5 ++++- src/js/icons.js | 52 +++++++++++++++++++++++++++++++++++++++++++++++ src/js/index.js | 3 +-- 4 files changed, 97 insertions(+), 7 deletions(-) create mode 100644 src/js/icons.js diff --git a/package-lock.json b/package-lock.json index 4a3136f..1ae08e4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1015,12 +1015,48 @@ "to-fast-properties": "^2.0.0" } }, - "@fortawesome/fontawesome-free": { - "version": "5.13.0", - "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-5.13.0.tgz", - "integrity": "sha512-xKOeQEl5O47GPZYIMToj6uuA2syyFlq9EMSl2ui0uytjY9xbe8XS0pexNWmxrdcCyNGyDmLyYw5FtKsalBUeOg==", + "@fortawesome/fontawesome-common-types": { + "version": "0.2.28", + "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-0.2.28.tgz", + "integrity": "sha512-gtis2/5yLdfI6n0ia0jH7NJs5i/Z/8M/ZbQL6jXQhCthEOe5Cr5NcQPhgTvFxNOtURE03/ZqUcEskdn2M+QaBg==", "dev": true }, + "@fortawesome/fontawesome-svg-core": { + "version": "1.2.28", + "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-svg-core/-/fontawesome-svg-core-1.2.28.tgz", + "integrity": "sha512-4LeaNHWvrneoU0i8b5RTOJHKx7E+y7jYejplR7uSVB34+mp3Veg7cbKk7NBCLiI4TyoWS1wh9ZdoyLJR8wSAdg==", + "dev": true, + "requires": { + "@fortawesome/fontawesome-common-types": "^0.2.28" + } + }, + "@fortawesome/free-brands-svg-icons": { + "version": "5.13.0", + "resolved": "https://registry.npmjs.org/@fortawesome/free-brands-svg-icons/-/free-brands-svg-icons-5.13.0.tgz", + "integrity": "sha512-/6xXiJFCMEQxqxXbL0FPJpwq5Cv6MRrjsbJEmH/t5vOvB4dILDpnY0f7zZSlA8+TG7jwlt12miF/yZpZkykucA==", + "dev": true, + "requires": { + "@fortawesome/fontawesome-common-types": "^0.2.28" + } + }, + "@fortawesome/free-regular-svg-icons": { + "version": "5.13.0", + "resolved": "https://registry.npmjs.org/@fortawesome/free-regular-svg-icons/-/free-regular-svg-icons-5.13.0.tgz", + "integrity": "sha512-70FAyiS5j+ANYD4dh9NGowTorNDnyvQHHpCM7FpnF7GxtDjBUCKdrFqCPzesEIpNDFNd+La3vex+jDk4nnUfpA==", + "dev": true, + "requires": { + "@fortawesome/fontawesome-common-types": "^0.2.28" + } + }, + "@fortawesome/free-solid-svg-icons": { + "version": "5.13.0", + "resolved": "https://registry.npmjs.org/@fortawesome/free-solid-svg-icons/-/free-solid-svg-icons-5.13.0.tgz", + "integrity": "sha512-IHUgDJdomv6YtG4p3zl1B5wWf9ffinHIvebqQOmV3U+3SLw4fC+LUCCgwfETkbTtjy5/Qws2VoVf6z/ETQpFpg==", + "dev": true, + "requires": { + "@fortawesome/fontawesome-common-types": "^0.2.28" + } + }, "@sphinxxxx/color-conversion": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/@sphinxxxx/color-conversion/-/color-conversion-2.2.2.tgz", diff --git a/package.json b/package.json index f7d6985..ba351be 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,10 @@ "@babel/plugin-proposal-class-properties": "^7.8.3", "@babel/polyfill": "^7.8.7", "@babel/preset-env": "^7.9.5", - "@fortawesome/fontawesome-free": "^5.8.1", + "@fortawesome/fontawesome-svg-core": "1.2.28", + "@fortawesome/free-brands-svg-icons": "5.13.0", + "@fortawesome/free-regular-svg-icons": "5.13.0", + "@fortawesome/free-solid-svg-icons": "5.13.0", "babel-loader": "^8.1.0", "babel-preset-minify": "^0.5.0", "clean-webpack-plugin": "3.0.0", diff --git a/src/js/icons.js b/src/js/icons.js new file mode 100644 index 0000000..3c58300 --- /dev/null +++ b/src/js/icons.js @@ -0,0 +1,52 @@ +import { library, dom } from "@fortawesome/fontawesome-svg-core"; +import { + faUndo, + faTrash, + faCheck, + faRedo, + faMousePointer, + faPencilAlt, + faEraser, + faImage, + faFont, + faSave, + faUpload, + faShareSquare, + faAngleLeft, + faAngleRight, + faSortDown, + faExpandArrowsAlt, +} from "@fortawesome/free-solid-svg-icons"; +import { + faSquare, + faCircle, + faFile, + faFileAlt, + faPlusSquare, +} from "@fortawesome/free-regular-svg-icons"; + +library.add( + faUndo, + faTrash, + faCheck, + faRedo, + faMousePointer, + faPencilAlt, + faEraser, + faImage, + faFont, + faSave, + faUpload, + faShareSquare, + faAngleLeft, + faAngleRight, + faSortDown, + faExpandArrowsAlt, + faSquare, + faCircle, + faFile, + faFileAlt, + faPlusSquare +); + +dom.i2svg() \ No newline at end of file diff --git a/src/js/index.js b/src/js/index.js index 55472dd..1e15468 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -1,9 +1,8 @@ import "jquery-ui/ui/core"; import "jquery-ui/ui/widgets/draggable"; -import "@fortawesome/fontawesome-free/js/all"; - import "../css/main.css"; +import "./icons"; import main from "./main"; $(document).ready(function () {