Ilya
03/05/2020, 8:39 AMconfig.resolve.modules.push("processedResources/Js/main");
config.module.rules.push(
{
test: /\.svg$/,
use: ['@svgr/webpack']
}
);
2) included in build.gradle.kts
dependencies {
..
implementation(npm("@svgr/webpack", "5.2.0"))
}
3) placed all svg's into resources/svg/...
4) import it in kotlin like @JsModule("svg/file.svg")
5) then when i run gradle browserDevelopmentWebpack
I get for every svg:
ERROR in .../build/processedResources/Js/main/img/svg/file.svg
Module not found: Error: Can't resolve 'react' in ...
Can somebody please point at what is wrong?Ivan Kubyshkin [JetBrains]
03/05/2020, 8:52 AMIlya
03/05/2020, 9:50 AMIlya
03/05/2020, 3:15 PMIlya Goncharov [JB]
03/10/2020, 2:47 PMsvgr
produces react components from svg, and after it process svg
file, it produces js file with require('react')
inside
So when webpack further process this intemediate js file it tries to require react
with resolve.modules
and logically it should be found in js/node_modules
, but this directory is not parent for processedResources
, so that’s why webpack couldn’t find anything. WA is manually add absolute path to node_modules
Add this to resolve.js
config.resolve.modules.push(require("path").resolve(__dirname, "../../node_modules"));
Ilya
03/11/2020, 2:52 AM