@trackunit/iris-app-webpack-plugin 0.0.159 → 0.0.161
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [0.0.161](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.160...iris-app-webpack-plugin/0.0.161) (2023-12-13)
|
|
6
|
+
|
|
7
|
+
## [0.0.160](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.159...iris-app-webpack-plugin/0.0.160) (2023-12-07)
|
|
8
|
+
|
|
5
9
|
## [0.0.159](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.158...iris-app-webpack-plugin/0.0.159) (2023-12-04)
|
|
6
10
|
|
|
7
11
|
## [0.0.158](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.157...iris-app-webpack-plugin/0.0.158) (2023-11-29)
|
package/package.json
CHANGED
|
@@ -9,6 +9,8 @@ const path = tslib_1.__importStar(require("path"));
|
|
|
9
9
|
const isTranslationKey = (object) => {
|
|
10
10
|
return !!(object === null || object === void 0 ? void 0 : object.key);
|
|
11
11
|
};
|
|
12
|
+
const RESET = "\x1b[0m";
|
|
13
|
+
const GREEN = "\x1b[32m";
|
|
12
14
|
/**
|
|
13
15
|
* Webpack plugin that generates a manifest.json file
|
|
14
16
|
*/
|
|
@@ -39,6 +41,13 @@ class TrackunitIrisAppWebpackPlugin {
|
|
|
39
41
|
// RawSource is one of the "sources" classes that should be used
|
|
40
42
|
// to represent asset sources in compilation.
|
|
41
43
|
const { RawSource } = webpack.sources;
|
|
44
|
+
compiler.hooks.done.tap("AfterBuildPlugin", stats => {
|
|
45
|
+
if (!stats.hasErrors()) {
|
|
46
|
+
setTimeout(() => {
|
|
47
|
+
console.log(GREEN, "\n✨ Iris App is now started, check it out ✨\nhttps://new.manager.trackunit.com/iris-sdk-portal/main#runLocal\n", RESET);
|
|
48
|
+
}, 0);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
42
51
|
// Tapping to the "thisCompilation" hook in order to further tap
|
|
43
52
|
// to the compilation process on an earlier stage.
|
|
44
53
|
compiler.hooks.thisCompilation.tap(pluginName, (compilation) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TrackunitIrisAppWebpackPlugin.js","sourceRoot":"","sources":["../../../../../../libs/iris-app-sdk/iris-app-webpack-plugin/src/lib/TrackunitIrisAppWebpackPlugin.ts"],"names":[],"mappings":";;;;AAAA,0DAAuH;AACvH,2CAAoC;AACpC,+CAAyB;AACzB,mDAA6B;AAS7B,MAAM,gBAAgB,GAAG,CAAC,MAA0D,EAA4B,EAAE;IAChH,OAAO,CAAC,CAAC,CAAC,MAA2B,aAA3B,MAAM,uBAAN,MAAM,CAAuB,GAAG,CAAA,CAAC;AAC7C,CAAC,CAAC;AAEF;;GAEG;AACH,MAAa,6BAA6B;IACxC;;OAEG;IACH,YAA2B,OAA8C;QAA9C,YAAO,GAAP,OAAO,CAAuC;IAAG,CAAC;IAE7E;;;;;;;;OAQG;IACI,KAAK,CAAC,QAAqB;QAChC,MAAM,UAAU,GAAG,6BAA6B,CAAC,IAAI,CAAC;QAEtD,oEAAoE;QACpE,0DAA0D;QAC1D,uEAAuE;QACvE,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC;QAE7B,kEAAkE;QAClE,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;QAEhC,gEAAgE;QAChE,6CAA6C;QAC7C,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;QAEtC,gEAAgE;QAChE,kDAAkD;QAClD,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,WAA2B,EAAE,EAAE;YAC7E,iEAAiE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nF,WAAW,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC;gBAElE,MAAM,GAAG,GAAG,IAAA,mBAAM,EAAC,IAAA,8BAAe,EAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC;gBAE3D,IAAI,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;gBACxD,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC;gBAC/D,oEAAoE;gBACpE,oDAAoD;gBACpD,WAAW,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;YAC3D,CAAC,CAAA,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA/KD,sEA+KC","sourcesContent":["import { irisAppCspInput, IrisAppManifest, languageKeys, TranslationKey, Translations } from \"@trackunit/iris-app-api\";\nimport { getCSP } from \"csp-header\";\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport * as wp from \"webpack\";\n\ninterface ITrackunitIrisAppWebpackPluginOptions {\n nxRootDir: string;\n appDir: string;\n manifest: IrisAppManifest;\n}\n\nconst isTranslationKey = (object: string | Translations | TranslationKey | undefined): object is TranslationKey => {\n return !!(object as { key?: string })?.key;\n};\n\n/**\n * Webpack plugin that generates a manifest.json file\n */\nexport class TrackunitIrisAppWebpackPlugin {\n /**\n * @param options - Plugin options\n */\n public constructor(private options: ITrackunitIrisAppWebpackPluginOptions) {}\n\n /**\n Webpack plugin for generating a Markdown file from app manifest and index HTML file.\n *\n @class\n @public\n @param {object} options - Plugin options object\n @param {string} options.appDir - Directory path where the app resides\n @param {object} options.manifest - Object containing the app's manifest\n */\n public apply(compiler: wp.Compiler) {\n const pluginName = TrackunitIrisAppWebpackPlugin.name;\n\n // webpack module instance can be accessed from the compiler object,\n // this ensures that correct version of the module is used\n // (do not require/import the webpack or any symbols from it directly).\n const { webpack } = compiler;\n\n // Compilation object gives us reference to some useful constants.\n const { Compilation } = webpack;\n\n // RawSource is one of the \"sources\" classes that should be used\n // to represent asset sources in compilation.\n const { RawSource } = webpack.sources;\n\n // Tapping to the \"thisCompilation\" hook in order to further tap\n // to the compilation process on an earlier stage.\n compiler.hooks.thisCompilation.tap(pluginName, (compilation: wp.Compilation) => {\n // Tapping to the assets processing pipeline on a specific stage.\n compilation.hooks.processAssets.tap(\n {\n name: pluginName,\n\n // Using one of the later asset processing stages to ensure\n // that all assets were already added to the compilation by other plugins.\n stage: Compilation.PROCESS_ASSETS_STAGE_DERIVED,\n },\n async assets => {\n // \"assets\" is an object that contains all assets\n // in the compilation, the keys of the object are pathnames of the assets\n // and the values are file sources.\n\n // Iterating over all the assets and\n // generating content for our Markdown file.\n if (!this.options?.manifest) {\n throw Error(\"you must provide a app manifest\");\n }\n const manifest = this.options.manifest;\n const indexContents = fs.readFileSync(path.join(__dirname, \"index.html\"), \"utf8\");\n\n const manifestJson = this.options.manifest;\n manifestJson.extensions = this.options.manifest.extensions;\n\n this.options.manifest.extensions?.forEach(extension => {\n const translationKey =\n extension.type !== \"IRIS_APP_SETTINGS_EXTENSION\" &&\n extension.type !== \"WIDGET_EXTENSION\" &&\n extension.menuItem &&\n extension.menuItem.name;\n\n if (translationKey) {\n if (isTranslationKey(translationKey)) {\n const menuItemName = translationKey;\n const menuItemNameKey = menuItemName.key;\n\n languageKeys.forEach(langugageCode => {\n const translationFilePath = path.join(\n extension.sourceRoot,\n \"locales\",\n langugageCode,\n \"translation.json\"\n );\n if (fs.existsSync(translationFilePath)) {\n const translations = JSON.parse(fs.readFileSync(translationFilePath, \"utf8\"));\n //@ts-ignore - suppressImplicitAnyIndexErrors\n // Here we substitute the translation key with the actual translation\n extension.menuItem.name[langugageCode] = translations[menuItemNameKey];\n }\n });\n delete (menuItemName as { key?: string }).key;\n }\n }\n const headerTranslationKey =\n extension.type === \"WIDGET_EXTENSION\" && extension.header && extension.header.name;\n if (headerTranslationKey) {\n if (isTranslationKey(headerTranslationKey)) {\n const menuItemName = headerTranslationKey;\n const menuItemNameKey = menuItemName.key;\n\n languageKeys.forEach(langugageCode => {\n const translationFilePath = path.join(\n extension.sourceRoot,\n \"locales\",\n langugageCode,\n \"translation.json\"\n );\n if (fs.existsSync(translationFilePath)) {\n const translations = JSON.parse(fs.readFileSync(translationFilePath, \"utf8\"));\n //@ts-ignore - suppressImplicitAnyIndexErrors\n // Here we substitute the translation key with the actual translation\n extension.header.name[langugageCode] = translations[menuItemNameKey];\n }\n });\n delete (menuItemName as { key?: string }).key;\n }\n }\n\n if (extension.type === \"REPORT_EXTENSION\" && isTranslationKey(extension.menuItem?.description)) {\n const description = extension.menuItem.description;\n const menuItemDescriptionKey = description.key;\n\n languageKeys.forEach(langugageCode => {\n const translationFilePath = path.join(\n extension.sourceRoot,\n \"locales\",\n langugageCode,\n \"translation.json\"\n );\n if (fs.existsSync(translationFilePath)) {\n const translations = JSON.parse(fs.readFileSync(translationFilePath, \"utf8\"));\n //@ts-ignore - suppressImplicitAnyIndexErrors\n // Here we substitute the translation key with the actual translation\n extension.menuItem.description[langugageCode] = translations[menuItemDescriptionKey];\n }\n });\n delete (description as { key?: string }).key;\n }\n if (extension.type === \"ASSET_HOME_EXTENSION\" || extension.type === \"FLEET_EXTENSION\") {\n if (extension.conditions?.brand) {\n if (Array.isArray(extension.conditions.brand)) {\n extension.conditions.brand.forEach(brand => {\n if (typeof brand !== \"string\") {\n brand.pattern = brand.pattern.toString();\n }\n });\n } else if (typeof extension.conditions.brand !== \"string\") {\n extension.conditions.brand.pattern = extension.conditions.brand.pattern.toString();\n }\n }\n if (extension.conditions?.model) {\n if (Array.isArray(extension.conditions.model)) {\n extension.conditions.model.forEach(model => {\n if (typeof model !== \"string\") {\n model.pattern = model.pattern.toString();\n }\n });\n } else if (typeof extension.conditions.model !== \"string\") {\n extension.conditions.model.pattern = extension.conditions.model.pattern.toString();\n }\n }\n }\n });\n\n manifestJson.extensions = this.options.manifest.extensions;\n compilation.emitAsset(\"manifest.json\", new RawSource(JSON.stringify(manifestJson, null, 2)));\n\n const packageJson = fs.readFileSync(`${this.options.appDir}/package.json`, \"utf8\");\n compilation.emitAsset(\"package.json\", new RawSource(packageJson));\n\n const csp = getCSP(irisAppCspInput(manifest.validDomains));\n\n let html = indexContents.replace(\"{{cspContent}}\", csp);\n html = html.replace(\"{{scope}}\", JSON.parse(packageJson).name);\n // Adding new asset to the compilation, so it would be automatically\n // generated by the webpack in the output directory.\n compilation.emitAsset(\"index.html\", new RawSource(html));\n }\n );\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TrackunitIrisAppWebpackPlugin.js","sourceRoot":"","sources":["../../../../../../libs/iris-app-sdk/iris-app-webpack-plugin/src/lib/TrackunitIrisAppWebpackPlugin.ts"],"names":[],"mappings":";;;;AAAA,0DAAuH;AACvH,2CAAoC;AACpC,+CAAyB;AACzB,mDAA6B;AAS7B,MAAM,gBAAgB,GAAG,CAAC,MAA0D,EAA4B,EAAE;IAChH,OAAO,CAAC,CAAC,CAAC,MAA2B,aAA3B,MAAM,uBAAN,MAAM,CAAuB,GAAG,CAAA,CAAC;AAC7C,CAAC,CAAC;AAEF,MAAM,KAAK,GAAG,SAAS,CAAC;AACxB,MAAM,KAAK,GAAG,UAAU,CAAC;AACzB;;GAEG;AACH,MAAa,6BAA6B;IACxC;;OAEG;IACH,YAA2B,OAA8C;QAA9C,YAAO,GAAP,OAAO,CAAuC;IAAG,CAAC;IAE7E;;;;;;;;OAQG;IACI,KAAK,CAAC,QAAqB;QAChC,MAAM,UAAU,GAAG,6BAA6B,CAAC,IAAI,CAAC;QAEtD,oEAAoE;QACpE,0DAA0D;QAC1D,uEAAuE;QACvE,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC;QAE7B,kEAAkE;QAClE,MAAM,EAAE,WAAW,EAAE,GAAG,OAA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,CAAC,KAAK,KAAK,QAAQ,EAAE;gCACzD,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,GAAG,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;6BACpF;yBACF;qBACF;gBACH,CAAC,CAAC,CAAC;gBAEH,YAAY,CAAC,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC;gBAC3D,WAAW,CAAC,SAAS,CAAC,eAAe,EAAE,IAAI,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;gBAE7F,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,eAAe,EAAE,MAAM,CAAC,CAAC;gBACnF,WAAW,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC;gBAElE,MAAM,GAAG,GAAG,IAAA,mBAAM,EAAC,IAAA,8BAAe,EAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC;gBAE3D,IAAI,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;gBACxD,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC;gBAC/D,oEAAoE;gBACpE,oDAAoD;gBACpD,WAAW,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;YAC3D,CAAC,CAAA,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA3LD,sEA2LC","sourcesContent":["import { irisAppCspInput, IrisAppManifest, languageKeys, TranslationKey, Translations } from \"@trackunit/iris-app-api\";\nimport { getCSP } from \"csp-header\";\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport * as wp from \"webpack\";\n\ninterface ITrackunitIrisAppWebpackPluginOptions {\n nxRootDir: string;\n appDir: string;\n manifest: IrisAppManifest;\n}\n\nconst isTranslationKey = (object: string | Translations | TranslationKey | undefined): object is TranslationKey => {\n return !!(object as { key?: string })?.key;\n};\n\nconst RESET = \"\\x1b[0m\";\nconst GREEN = \"\\x1b[32m\";\n/**\n * Webpack plugin that generates a manifest.json file\n */\nexport class TrackunitIrisAppWebpackPlugin {\n /**\n * @param options - Plugin options\n */\n public constructor(private options: ITrackunitIrisAppWebpackPluginOptions) {}\n\n /**\n Webpack plugin for generating a Markdown file from app manifest and index HTML file.\n *\n @class\n @public\n @param {object} options - Plugin options object\n @param {string} options.appDir - Directory path where the app resides\n @param {object} options.manifest - Object containing the app's manifest\n */\n public apply(compiler: wp.Compiler) {\n const pluginName = TrackunitIrisAppWebpackPlugin.name;\n\n // webpack module instance can be accessed from the compiler object,\n // this ensures that correct version of the module is used\n // (do not require/import the webpack or any symbols from it directly).\n const { webpack } = compiler;\n\n // Compilation object gives us reference to some useful constants.\n const { Compilation } = webpack;\n\n // RawSource is one of the \"sources\" classes that should be used\n // to represent asset sources in compilation.\n const { RawSource } = webpack.sources;\n\n compiler.hooks.done.tap(\"AfterBuildPlugin\", stats => {\n if (!stats.hasErrors()) {\n setTimeout(() => {\n console.log(\n GREEN,\n \"\\n✨ Iris App is now started, check it out ✨\\nhttps://new.manager.trackunit.com/iris-sdk-portal/main#runLocal\\n\",\n RESET\n );\n }, 0);\n }\n });\n\n // Tapping to the \"thisCompilation\" hook in order to further tap\n // to the compilation process on an earlier stage.\n compiler.hooks.thisCompilation.tap(pluginName, (compilation: wp.Compilation) => {\n // Tapping to the assets processing pipeline on a specific stage.\n compilation.hooks.processAssets.tap(\n {\n name: pluginName,\n\n // Using one of the later asset processing stages to ensure\n // that all assets were already added to the compilation by other plugins.\n stage: Compilation.PROCESS_ASSETS_STAGE_DERIVED,\n },\n async assets => {\n // \"assets\" is an object that contains all assets\n // in the compilation, the keys of the object are pathnames of the assets\n // and the values are file sources.\n\n // Iterating over all the assets and\n // generating content for our Markdown file.\n if (!this.options?.manifest) {\n throw Error(\"you must provide a app manifest\");\n }\n const manifest = this.options.manifest;\n const indexContents = fs.readFileSync(path.join(__dirname, \"index.html\"), \"utf8\");\n\n const manifestJson = this.options.manifest;\n manifestJson.extensions = this.options.manifest.extensions;\n\n this.options.manifest.extensions?.forEach(extension => {\n const translationKey =\n extension.type !== \"IRIS_APP_SETTINGS_EXTENSION\" &&\n extension.type !== \"WIDGET_EXTENSION\" &&\n extension.menuItem &&\n extension.menuItem.name;\n\n if (translationKey) {\n if (isTranslationKey(translationKey)) {\n const menuItemName = translationKey;\n const menuItemNameKey = menuItemName.key;\n\n languageKeys.forEach(langugageCode => {\n const translationFilePath = path.join(\n extension.sourceRoot,\n \"locales\",\n langugageCode,\n \"translation.json\"\n );\n if (fs.existsSync(translationFilePath)) {\n const translations = JSON.parse(fs.readFileSync(translationFilePath, \"utf8\"));\n //@ts-ignore - suppressImplicitAnyIndexErrors\n // Here we substitute the translation key with the actual translation\n extension.menuItem.name[langugageCode] = translations[menuItemNameKey];\n }\n });\n delete (menuItemName as { key?: string }).key;\n }\n }\n const headerTranslationKey =\n extension.type === \"WIDGET_EXTENSION\" && extension.header && extension.header.name;\n if (headerTranslationKey) {\n if (isTranslationKey(headerTranslationKey)) {\n const menuItemName = headerTranslationKey;\n const menuItemNameKey = menuItemName.key;\n\n languageKeys.forEach(langugageCode => {\n const translationFilePath = path.join(\n extension.sourceRoot,\n \"locales\",\n langugageCode,\n \"translation.json\"\n );\n if (fs.existsSync(translationFilePath)) {\n const translations = JSON.parse(fs.readFileSync(translationFilePath, \"utf8\"));\n //@ts-ignore - suppressImplicitAnyIndexErrors\n // Here we substitute the translation key with the actual translation\n extension.header.name[langugageCode] = translations[menuItemNameKey];\n }\n });\n delete (menuItemName as { key?: string }).key;\n }\n }\n\n if (extension.type === \"REPORT_EXTENSION\" && isTranslationKey(extension.menuItem?.description)) {\n const description = extension.menuItem.description;\n const menuItemDescriptionKey = description.key;\n\n languageKeys.forEach(langugageCode => {\n const translationFilePath = path.join(\n extension.sourceRoot,\n \"locales\",\n langugageCode,\n \"translation.json\"\n );\n if (fs.existsSync(translationFilePath)) {\n const translations = JSON.parse(fs.readFileSync(translationFilePath, \"utf8\"));\n //@ts-ignore - suppressImplicitAnyIndexErrors\n // Here we substitute the translation key with the actual translation\n extension.menuItem.description[langugageCode] = translations[menuItemDescriptionKey];\n }\n });\n delete (description as { key?: string }).key;\n }\n if (extension.type === \"ASSET_HOME_EXTENSION\" || extension.type === \"FLEET_EXTENSION\") {\n if (extension.conditions?.brand) {\n if (Array.isArray(extension.conditions.brand)) {\n extension.conditions.brand.forEach(brand => {\n if (typeof brand !== \"string\") {\n brand.pattern = brand.pattern.toString();\n }\n });\n } else if (typeof extension.conditions.brand !== \"string\") {\n extension.conditions.brand.pattern = extension.conditions.brand.pattern.toString();\n }\n }\n if (extension.conditions?.model) {\n if (Array.isArray(extension.conditions.model)) {\n extension.conditions.model.forEach(model => {\n if (typeof model !== \"string\") {\n model.pattern = model.pattern.toString();\n }\n });\n } else if (typeof extension.conditions.model !== \"string\") {\n extension.conditions.model.pattern = extension.conditions.model.pattern.toString();\n }\n }\n }\n });\n\n manifestJson.extensions = this.options.manifest.extensions;\n compilation.emitAsset(\"manifest.json\", new RawSource(JSON.stringify(manifestJson, null, 2)));\n\n const packageJson = fs.readFileSync(`${this.options.appDir}/package.json`, \"utf8\");\n compilation.emitAsset(\"package.json\", new RawSource(packageJson));\n\n const csp = getCSP(irisAppCspInput(manifest.validDomains));\n\n let html = indexContents.replace(\"{{cspContent}}\", csp);\n html = html.replace(\"{{scope}}\", JSON.parse(packageJson).name);\n // Adding new asset to the compilation, so it would be automatically\n // generated by the webpack in the output directory.\n compilation.emitAsset(\"index.html\", new RawSource(html));\n }\n );\n });\n }\n}\n"]}
|
package/src/lib/index.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<meta http-equiv="Content-Security-Policy" content="{{cspContent}}">
|
|
11
11
|
</head>
|
|
12
12
|
<body class="@container" style="margin: 0px; overflow: auto;">
|
|
13
|
-
<div id="single-spa-application:app" style="height:
|
|
13
|
+
<div id="single-spa-application:app" style="height: 100dvh">
|
|
14
14
|
</div>
|
|
15
15
|
</body>
|
|
16
16
|
</html>
|