Skip to content

Commit

Permalink
#669 fix js resources path
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex009 committed May 15, 2024
1 parent e3d837a commit 24f8e50
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal class JsAssetResourceGenerator(
val filePath: String = File(ASSETS_DIR, metadata.pathRelativeToBase.path).path
.replace("\\", "/")

val requireDeclaration = """require("$filePath")"""
val requireDeclaration = """require("./$filePath")"""
return CodeBlock.of(
"AssetResource(originalPath = js(%S) as String, rawPath = %S)",
requireDeclaration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal class JsFileResourceGenerator(
override fun imports(): List<ClassName> = emptyList()

override fun generateInitializer(metadata: FileMetadata): CodeBlock {
val requireDeclaration = """require("$FILES_DIR/${metadata.filePath.name}")"""
val requireDeclaration = """require("./$FILES_DIR/${metadata.filePath.name}")"""
return CodeBlock.of(
"FileResource(fileUrl = js(%S) as String)",
requireDeclaration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal class JsFontResourceGenerator(
override fun imports(): List<ClassName> = emptyList()

override fun generateInitializer(metadata: FontMetadata): CodeBlock {
val requireDeclaration = """require("$FONTS_DIR/${metadata.filePath.name}")"""
val requireDeclaration = """require("./$FONTS_DIR/${metadata.filePath.name}")"""
return CodeBlock.of(
"FontResource(fileUrl = js(%S) as String, fontFamily = %S)",
requireDeclaration,
Expand Down Expand Up @@ -95,7 +95,7 @@ internal class JsFontResourceGenerator(
val addFontsFun: FunSpec = FunSpec.builder("addFontsToPage")
.addCode(
"js(%S)",
"""require("$FONTS_DIR/$cssDeclarationsFileName")"""
"""require("./$FONTS_DIR/$cssDeclarationsFileName")"""
).build()
builder.addFunction(addFontsFun)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ internal class JsImageResourceGenerator(
}
}

val requireDeclaration: String = """require("$IMAGES_DIR/$fileName")"""
val darkRequireDeclaration: String = """require("$IMAGES_DIR/$darkFileName")"""
val requireDeclaration: String = """require("./$IMAGES_DIR/$fileName")"""
val darkRequireDeclaration: String = """require("./$IMAGES_DIR/$darkFileName")"""

return if (darkFileName != null) {
CodeBlock.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ internal class JsPluralResourceGenerator(
builder.addSuperinterface(Constants.Js.loaderHolderName)

builder.addJsFallbackProperty(
fallbackFilePath = LOCALIZATION_DIR + "/" + getFileNameForLanguage(LanguageType.Base)
fallbackFilePath = "./" + LOCALIZATION_DIR + "/" + getFileNameForLanguage(LanguageType.Base)
)
builder.addJsSupportedLocalesProperty(
bcpLangToPath = metadata.asSequence()
Expand All @@ -69,7 +69,7 @@ internal class JsPluralResourceGenerator(
LanguageType.fromLanguage(locale)
}.filterIsInstance<LanguageType.Locale>().map { language ->
val fileName: String = getFileNameForLanguage(language)
language.toBcpString() to "$LOCALIZATION_DIR/$fileName"
language.toBcpString() to "./$LOCALIZATION_DIR/$fileName"
}.toList()
)
builder.addJsContainerStringsLoaderProperty()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ internal class JsStringResourceGenerator(
builder.addSuperinterface(Constants.Js.loaderHolderName)

builder.addJsFallbackProperty(
fallbackFilePath = LOCALIZATION_DIR + "/" + getFileNameForLanguage(LanguageType.Base)
fallbackFilePath = "./" + LOCALIZATION_DIR + "/" + getFileNameForLanguage(LanguageType.Base)
)
builder.addJsSupportedLocalesProperty(
bcpLangToPath = metadata.asSequence()
Expand All @@ -69,7 +69,7 @@ internal class JsStringResourceGenerator(
LanguageType.fromLanguage(locale)
}.filterIsInstance<LanguageType.Locale>().map { language ->
val fileName: String = getFileNameForLanguage(language)
language.toBcpString() to "$LOCALIZATION_DIR/$fileName"
language.toBcpString() to "./$LOCALIZATION_DIR/$fileName"
}.toList()
)
builder.addJsContainerStringsLoaderProperty()
Expand Down

0 comments on commit 24f8e50

Please sign in to comment.