From 7edb451d179134038fb6ad8a80dd97a1f0836eb2 Mon Sep 17 00:00:00 2001 From: nobody Date: Tue, 10 Nov 2020 16:42:28 +0100 Subject: [PATCH] Improved: Font Awesome (Fonts only) (#170) --- core/constants.js | 2 +- core/mappings.js | 3 ++- core/request-analyzer.js | 2 +- core/resources.js | 3 +++ core/shorthands.js | 8 -------- modules/internal/targets.js | 2 ++ 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/core/constants.js b/core/constants.js index 66a5cc17..a2d8848e 100644 --- a/core/constants.js +++ b/core/constants.js @@ -203,7 +203,7 @@ const Regex = { 'BOOTSTRAP_DATEPICKER': /\/bootstrap-datepicker.*\.css/, 'FONT_AWESOME': /use\.fontawesome\.com\/fa-loader\.css/, 'FONT_AWESOME_WITH_CODE': /use\.fontawesome\.com\/[a-z0-9]{10}\.(js|css)/, - 'FONT_AWESOME_ONLY_FONTS': /\/font-awesome\/(?:\d{1,2}\.){1,3}\d{1,2}\/fonts\// + 'FONT_AWESOME_FONTS_ONLY': /\/fontawesome\/(?:\d{1,2}\.){1,3}\d{1,2}\/fonts\// }; const Links = { diff --git a/core/mappings.js b/core/mappings.js index 182cd595..d30b31d1 100644 --- a/core/mappings.js +++ b/core/mappings.js @@ -817,7 +817,8 @@ mappings.cdn = { 'bootstrap/{version}/js/bootstrap.min.': resources.bootstrapJS, 'bootstrap/{version}/css/bootstrap.min.': resources.bootstrapCSS, 'twitter-bootstrap/{version}/css/bootstrap': resources.bootstrapCSS, - 'font-awesome/{version}/css/font-awesome': resources.fontawesome + 'font-awesome/{version}/css/font-awesome': resources.fontawesome, + 'font-awesome/{version}/fonts/': resources.fontawesomeFontsOnly } }, // NetDNA Bootstrap diff --git a/core/request-analyzer.js b/core/request-analyzer.js index cde587ee..289e65d5 100644 --- a/core/request-analyzer.js +++ b/core/request-analyzer.js @@ -158,7 +158,7 @@ requestAnalyzer._findLocalTarget = function (resourceMappings, basePath, channel let bundle = targets.determineBundle(targetPath); if (bundle !== '') { filename = channelPath.split('/').pop(); - targetPath = ( RegExp('.*\.css$').test(filename) ) ? targetPath + filename : targetPath + filename + 'm'; + targetPath = ( filename.endsWith('.js') ) ? targetPath + filename + 'm' : targetPath + filename; targetPath = helpers.formatFilename(targetPath); } diff --git a/core/resources.js b/core/resources.js index 3493d198..bb53b563 100644 --- a/core/resources.js +++ b/core/resources.js @@ -381,6 +381,9 @@ var resources = { 'path': 'resources/fontawesome/{version}/js/all.min.jsm', 'type': 'application/javascript' }, + 'fontawesomeFontsOnly': { + 'path': 'resources/fontawesome/{version}/fonts/' + }, // GSAP 'gsapBundle': { 'path': 'resources/gsap/{version}/', diff --git a/core/shorthands.js b/core/shorthands.js index be5a54fb..7aca77f4 100644 --- a/core/shorthands.js +++ b/core/shorthands.js @@ -165,14 +165,6 @@ shorthands.specialFiles = function (channelHost, channelPath, searchString) { 'path': 'resources/google-charts/loader.jsm', 'bundle': '' }; - } else if (Regex.FONT_AWESOME_ONLY_FONTS.test(channelPath)) { - lastVersion = targets.setLastVersion('/fontawesome/4.'); - return { - 'source': channelHost, - 'versionDelivered': lastVersion, - 'path': 'resources/fontawesome/' + lastVersion + '/fonts/' + helpers.extractFilenameFromPath(channelPath), - 'bundle': 'Font Awesome (Fonts)' - }; } else { return false; } diff --git a/modules/internal/targets.js b/modules/internal/targets.js index ec16f6d3..4de43946 100644 --- a/modules/internal/targets.js +++ b/modules/internal/targets.js @@ -42,6 +42,8 @@ targets.determineBundle = function (path) { return 'Select2'; } else if (path.startsWith('/gsap/')) { return 'GSAP'; + } else if (Regex.FONT_AWESOME_FONTS_ONLY.test(path)) { + return 'Font Awesome (Fonts)'; } else { return ''; }