Skip to content

Commit 2876834

Browse files
committed
build: minify extensions framework
1 parent 68b4883 commit 2876834

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

gulpfile.js/index.js

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -789,12 +789,49 @@ function _renameExtensionConcatAsExtensionJSInDist(extensionName) {
789789
});
790790
}
791791

792+
const minifyableExtensions = ["CloseOthers", "CodeFolding", "DebugCommands", "Git",
793+
"HealthData", "JavaScriptCodeHints", "JavaScriptRefactoring", "QuickView"];
794+
// extensions that nned not be minified either coz they are single file extensions or some other reason.
795+
const nonMinifyExtensions = ["CSSAtRuleCodeHints", "CSSCodeHints",
796+
"CSSPseudoSelectorHints", "DarkTheme", "HandlebarsSupport", "HTMLCodeHints", "HtmlEntityCodeHints",
797+
"InlineColorEditor", "InlineTimingFunctionEditor", "JavaScriptQuickEdit", "JSLint",
798+
"LightTheme", "MDNDocs", "Phoenix-prettier", "PrefsCodeHints", "SVGCodeHints", "UrlCodeHints"
799+
];
792800
async function makeConcatExtensions() {
793-
await makeExtensionConcatJS("Git");
801+
let content = JSON.parse(fs.readFileSync(`src/extensions/default/DefaultExtensions.json`,
802+
"utf8"));
803+
const allExtensions = [...content.defaultExtensionsList, ...content.desktopOnly];
804+
805+
// 3) Validate no unknown extensions are present
806+
const knownExtensions = [
807+
...minifyableExtensions,
808+
...nonMinifyExtensions
809+
];
810+
811+
const unknownExtensions = allExtensions.filter(
812+
(ext) => !knownExtensions.includes(ext)
813+
);
814+
815+
if (unknownExtensions.length > 0) {
816+
throw new Error(
817+
`New extension(s) detected: ${unknownExtensions.join(", ")}. ` +
818+
`Please add them to either minifyableExtensions or ` +
819+
`nonMinifyExtensions array.`
820+
);
821+
}
822+
823+
// 4) Run concatenation for all concat-enabled extensions
824+
for (const extension of minifyableExtensions) {
825+
await makeExtensionConcatJS(extension);
826+
}
827+
828+
console.log("All extensions concatenated and minified!");
794829
}
795830

796831
async function _renameConcatExtensionsinDist() {
797-
await _renameExtensionConcatAsExtensionJSInDist("Git");
832+
for (const extension of minifyableExtensions) {
833+
await _renameExtensionConcatAsExtensionJSInDist(extension);
834+
}
798835
}
799836

800837
function createCacheManifest(srcFolder) {

0 commit comments

Comments
 (0)