forked from MichaelRocks/libphonenumber-android
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix packing test-resources for library js tests
- Loading branch information
Showing
2 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
val rootProjectAbsPath = rootProject.projectDir.absolutePath | ||
val path = """"$rootProjectAbsPath/library/build/generated/moko/jsMain/iomichaelrockslibphonenumber/res"""" | ||
val webpackConfig = File(projectDir, "webpack.config.d/pack-library-resources-generated.js") | ||
|
||
fun createWebpackConfig() { | ||
val configText = """const path = require('path'); | ||
const mokoResourcePath = path.resolve($path); | ||
config.module.rules.push({ | ||
test: /(ShortNumberMetadataProto_|PhoneNumberMetadataProto_|PhoneNumberMetadataProtoForTesting_|PhoneNumberAlternateFormatsProto_)[^.]+${'$'}/, | ||
include: [ | ||
path.resolve(mokoResourcePath, "files"), | ||
], | ||
type: 'asset/inline', | ||
generator: { | ||
dataUrl: content => { | ||
// Convert buffer content to base64 and prepend it with mimetype | ||
return `${'$'}{content.toString('base64')}` | ||
} | ||
} | ||
});""" | ||
webpackConfig.writeText(configText) | ||
} | ||
|
||
tasks.create("createPackResourcesWebpackConfig") { | ||
// Define the task's output | ||
outputs.file(webpackConfig) | ||
|
||
doFirst { | ||
createWebpackConfig() | ||
} | ||
} | ||
|
||
tasks.getByName("compileKotlinJs").dependsOn("createPackResourcesWebpackConfig") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters