Does anyone know how to access static files from t...
# react
s
Does anyone know how to access static files from the processedResources folder in a Kotlin/Browser project?
r
You can use webpack's
require("./path/to/resource")
but you need to configure appropriate loader (e.g. file-loader)
s
I’ve added the
file-loader
npm dependency and tried to add it using
Copy code
config.module.rules.push({
    test: /\.(png|jpg|jepg|gif|woff(2)?|ttf|eot|otf|svg|ico|toml)$/,
    use: ['file-loader'],
});
but it doesn’t seem to find my file whenever I use
Copy code
kotlinext.js.require("locales/en_US/strings.toml")
Am I using the wrong require?
r
try declaring external function
external fun require(name: String): dynamic
s
doesn’t seem to work. Also the error I am getting is
Error: Can't resolve 'locales/en_US/strings.toml' in '/Users/user/Documents/Projects/tbwp/build/js/packages/tbwp/kotlin'
r
try adding
config.resolve.modules.push("../../processedResources/Js/main");
to your webpack config
s
That seems to have fixed my error. Thank you!