mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
docs: add comments about how app.css+snapshot work
This commit is contained in:
@@ -81,7 +81,8 @@ function resolveModuleSnapshot(path, ext) {
|
||||
traceWrite(`Resolving module in SNAPSHOT context - path: '${path}' with ext: '${ext}'`, traceCategories.ModuleNameResolver);
|
||||
|
||||
// Platform module when in snapshot. So resolve modules with default android phone.
|
||||
// NB: The only module name that should ever be resolved while in snapshot is app.css
|
||||
// NB: The only module name that should ever be resolved while in snapshot is app.css, because it is
|
||||
// applied explicitly in the snapshot by [NativeScriptSnapshotPlugin](https://github.com/NativeScript/nativescript-dev-webpack/blob/48b26f412fd70c19dc0b9c7763e08e9505a0ae11/plugins/NativeScriptSnapshotPlugin/index.js#L48-L56)
|
||||
return new ModuleNameResolver({
|
||||
width: 400,
|
||||
height: 800,
|
||||
|
||||
@@ -343,6 +343,11 @@ const loadCss = profile(`"style-scope".loadCss`, (cssModule: string) => {
|
||||
applicationCommon.on("cssChanged", onCssChanged);
|
||||
applicationCommon.on("livesync", onLiveSync);
|
||||
|
||||
// Call to this method is injected in the application in:
|
||||
// - no-snapshot - code injected in app.ts by [bundle-config-loader](https://github.com/NativeScript/nativescript-dev-webpack/blob/9b1e34d8ef838006c9b575285c42d2304f5f02b5/bundle-config-loader.ts#L85-L92)
|
||||
// - with-snapshot - code injected in snapshot bundle by [NativeScriptSnapshotPlugin](https://github.com/NativeScript/nativescript-dev-webpack/blob/48b26f412fd70c19dc0b9c7763e08e9505a0ae11/plugins/NativeScriptSnapshotPlugin/index.js#L48-L56)
|
||||
// Having the app.css loaded in snapshot provides significant boost in startup (when using the ns-theme ~150 ms). However, because app.css is resolved at build-time,
|
||||
// when the snapshot is created - there is no way to use file qualifiers or change the name of on app.css
|
||||
export const loadAppCSS = profile("\"style-scope\".loadAppCSS", (args: applicationCommon.LoadAppCSSEventData) => {
|
||||
loadCss(args.cssFile);
|
||||
applicationCommon.off("loadAppCss", loadAppCSS);
|
||||
|
||||
Reference in New Issue
Block a user