Skip to content

Commit

Permalink
Revert: Re-add workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenc-nanashi committed May 21, 2024
1 parent f99aab9 commit 256f96f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ kotlin {
implementation(npm("raw-loader", "4.0.2"))
implementation(npm("file-loader", "6.2.0"))
implementation(npm("js-cookie", "2.2.1"))
implementation(npm("glob", "10.3.15"))
}
}
val jsTest by getting {
Expand Down
47 changes: 47 additions & 0 deletions webpack.config.d/coreRedirect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const path = require("path");
const { globSync } = require("glob");

const resourcePath = path.resolve(
__dirname,
"..",
"utaformatix-core",
"kotlin",
);
const resources = globSync(
resourcePath + "/**/*",
).map((resource) =>
"." + resource.replace(
resourcePath,
"",
).replace(/\\/g, "/")
);
if (resources.length === 0) throw new Error(`No resources found in ${resourcePath}`);

class MyResolverPlugin {
apply(resolver) {
const target = resolver.ensureHook("resolve");
resolver
.getHook("resolve")
.tapAsync("MyResolverPlugin", (request, resolveContext, callback) => {
if (
resources.includes(request.request) &&
!request.path.startsWith(resourcePath)
) {
return resolver.doResolve(
target,
{
...request,
path: resourcePath,
request: request.request,
},
null,
resolveContext,
callback,
);
}
callback();
});
}
}

config.resolve.plugins = [new MyResolverPlugin()];

0 comments on commit 256f96f

Please sign in to comment.