Skip to content

Commit c0d1001

Browse files
committed
Use tree-shaking when importing FontAwesome icons to decrease bundle size
Signed-off-by: Olga Bulat <obulat@gmail.com>
1 parent b0a6311 commit c0d1001

File tree

4 files changed

+35
-42
lines changed

4 files changed

+35
-42
lines changed

src/components/LicenseIconography.vue

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,8 @@
1515
</template>
1616

1717
<script>
18-
import { library } from '@fortawesome/fontawesome-svg-core'
19-
import {
20-
faCreativeCommons,
21-
faCreativeCommonsBy,
22-
faCreativeCommonsNc,
23-
faCreativeCommonsNd,
24-
faCreativeCommonsSa,
25-
faCreativeCommonsZero
26-
} from '@fortawesome/free-brands-svg-icons/'
2718
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
28-
library.add(
29-
faCreativeCommons,
30-
faCreativeCommonsBy,
31-
faCreativeCommonsNc,
32-
faCreativeCommonsNd,
33-
faCreativeCommonsSa,
34-
faCreativeCommonsZero
35-
)
19+
3620
/**
3721
* ### License icons are hieroglyphs for the aspects of a license.
3822
*

src/components/PrintMediaLicenseCode.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@
88
<LicenseCode ref="licenseCode" attribution-type="print"/>
99
</div>
1010
</b-tab-item>
11-
<b-tab-item icon-pack="fas" icon="copy">
11+
<b-tab-item>
1212
<template slot="header">
1313
<a class="copyBtn"
1414
data-clipboard-target="#attribution-plaintext">
15-
<b-icon
16-
icon-pack="fas"
17-
icon="copy"/>
15+
<font-awesome-icon icon="copy" />
1816
<span class="button-text">{{ copyText }}</span>
1917
</a>
2018
</template>
@@ -27,10 +25,12 @@
2725
import Clipboard from 'clipboard'
2826
import { mapGetters } from 'vuex'
2927
import LicenseCode from './LicenseCode'
28+
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
3029
3130
export default {
3231
name: 'PrintMediaLicenseCode',
3332
components: {
33+
FontAwesomeIcon,
3434
LicenseCode
3535
},
3636
props: {
@@ -111,6 +111,9 @@ export default {
111111
}
112112
</script>
113113
<style lang="scss">
114+
.copyBtn svg {
115+
margin-right: 3px;
116+
}
114117
115118
.attribution-tab .photo-license-icon {
116119
height: 1.4rem;

src/components/WebLicenseCode.vue

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,11 @@
1717
/>
1818
</div>
1919
</b-tab-item>
20-
<b-tab-item
21-
icon-pack="fas"
22-
icon="copy"
23-
>
20+
<b-tab-item>
2421
<template slot="header">
2522
<a class="copyBtn"
2623
:data-clipboard-target=this.clipboardTarget()>
27-
<b-icon
28-
icon-pack="fas"
29-
icon="copy"/>
24+
<font-awesome-icon icon="copy" />
3025
<span class="button-text">{{ copyText }}
3126
</span>
3227
</a>
@@ -41,10 +36,12 @@ import Clipboard from 'clipboard'
4136
import { mapGetters } from 'vuex'
4237
import LicenseCode from './LicenseCode'
4338
import { generateHTML } from '../utils/license-utilities'
39+
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
4440
4541
export default {
4642
name: 'WebLicenseCode',
4743
components: {
44+
FontAwesomeIcon,
4845
LicenseCode
4946
},
5047
props: {
@@ -140,6 +137,10 @@ export default {
140137
</script>
141138
<style lang="scss">
142139
140+
.copyBtn svg {
141+
margin-right: 3px;
142+
}
143+
143144
#attribution-richtext>p>span,
144145
#attribution-richtext .photo-license-icons{
145146
height: 26px;

src/main.js

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,33 @@
11
import Vue from 'vue'
22
import Buefy from 'buefy'
3+
import 'buefy/dist/buefy.css'
34
import i18n from './i18n'
45
import VueAnalytics from 'vue-analytics'
56
import App from './App.vue'
67
import store from './store'
78

89
import { library } from '@fortawesome/fontawesome-svg-core'
9-
// internal icons
10-
import {
11-
faCheck, faCheckCircle, faInfoCircle, faExclamationTriangle, faExclamationCircle,
12-
faArrowUp, faAngleRight, faAngleLeft, faAngleDown, faUserCircle, faQuestionCircle,
13-
faEye, faEyeSlash, faCaretDown, faCaretUp, faUpload, faCopy, faCircle
14-
} from '@fortawesome/free-solid-svg-icons'
10+
import { faCopy } from '@fortawesome/free-solid-svg-icons/faCopy'
11+
import { faCreativeCommons } from '@fortawesome/free-brands-svg-icons/faCreativeCommons'
12+
import { faCreativeCommonsBy } from '@fortawesome/free-brands-svg-icons/faCreativeCommonsBy'
13+
import { faCreativeCommonsNc } from '@fortawesome/free-brands-svg-icons/faCreativeCommonsNc'
14+
import { faCreativeCommonsNd } from '@fortawesome/free-brands-svg-icons/faCreativeCommonsNd'
15+
import { faCreativeCommonsSa } from '@fortawesome/free-brands-svg-icons/faCreativeCommonsSa'
16+
import { faCreativeCommonsZero } from '@fortawesome/free-brands-svg-icons/faCreativeCommonsZero'
1517
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
16-
17-
library.add(faCheck, faCheckCircle, faInfoCircle, faExclamationTriangle, faExclamationCircle,
18-
faArrowUp, faAngleRight, faAngleLeft, faAngleDown, faUserCircle, faQuestionCircle,
19-
faEye, faEyeSlash, faCaretDown, faCaretUp, faUpload, faCopy, faCircle)
18+
library.add(
19+
faCopy,
20+
faCreativeCommons,
21+
faCreativeCommonsBy,
22+
faCreativeCommonsNc,
23+
faCreativeCommonsNd,
24+
faCreativeCommonsSa,
25+
faCreativeCommonsZero
26+
)
2027
Vue.component('vue-fontawesome', FontAwesomeIcon)
2128
Vue.config.productionTip = false
22-
Vue.use(Buefy, {
23-
defaultIconComponent: 'vue-fontawesome',
24-
defaultIconPack: 'fas'
25-
})
29+
Vue.use(Buefy)
30+
2631
if (process.env.NODE_ENV === 'production') {
2732
Vue.use(VueAnalytics, {
2833
id: 'UA-2010376-41',

0 commit comments

Comments
 (0)