mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
fix(webpack): fix fragment css not being applied with webpack (#5172)
Support css files for fragments to be registered using global.registerModule and global.registerWebpackModules.
This commit is contained in:
committed by
Vasil Chimev
parent
0986315374
commit
60773e7545
@@ -115,15 +115,28 @@ function loadCustomComponent(componentPath: string, componentName?: string, attr
|
||||
result = getComponentModule(componentName, componentPath, attributes, context);
|
||||
}
|
||||
|
||||
// Add component CSS file if exists.
|
||||
var cssFilePath = resolveFileName(fullComponentPathFilePathWithoutExt, "css");
|
||||
if (cssFilePath) {
|
||||
if (parentPage && typeof (<any>parentPage).addCssFile === "function") {
|
||||
(<any>parentPage).addCssFile(cssFilePath);
|
||||
} else {
|
||||
ensureTrace();
|
||||
// webpack modules require paths to be relative to /app folder.
|
||||
let cssModulePath = fullComponentPathFilePathWithoutExt + ".css";
|
||||
if (cssModulePath.startsWith("/")) {
|
||||
var app = knownFolders.currentApp().path + "/";
|
||||
if (cssModulePath.startsWith(app)) {
|
||||
cssModulePath = "./" + cssModulePath.substr(app.length);
|
||||
}
|
||||
}
|
||||
|
||||
trace.write("CSS file found but no page specified. Please specify page in the options!", trace.categories.Error, trace.messageType.error);
|
||||
// Add CSS from webpack module if exists.
|
||||
if (global.moduleExists(cssModulePath)) {
|
||||
(<any>parentPage).addCssFile(cssModulePath);
|
||||
} else {
|
||||
var cssFilePath = resolveFileName(fullComponentPathFilePathWithoutExt, "css");
|
||||
// Add component CSS file if exists.
|
||||
if (cssFilePath) {
|
||||
if (parentPage && typeof (<any>parentPage).addCssFile === "function") {
|
||||
(<any>parentPage).addCssFile(cssFilePath);
|
||||
} else {
|
||||
ensureTrace();
|
||||
trace.write("CSS file found but no page specified. Please specify page in the options!", trace.categories.Error, trace.messageType.error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user