Closed yangtheman closed 1 year ago
Answering my own question, using path.resolve(__dirname, "")
worked for me.
importMapper: (path) => {
let transformed = path
if (path.match(/^DesignSystem\//)) {
transformed = path.replace(/^DesignSystem\//, path.resolve(__dirname, "") + '/app/javascript/design_system/');
} else if (path.match(/^Shared\//)) {
transformed = path.replace(/^Shared\//, path.resolve(__dirname, "") + '/app/javascript/shared/');
};
console.log(`Received ${path} --> converting to ${transformed}`);
return transformed
},
sorry for the late reply... what you did works. The path resolution would be done by the plugin for you because the importMapper is called before... the catch was that by starting your replaced path with app/
that wasn't
a correct relative import and so it wasn't resolved.
I see that you would have an harder life relying on the plugin resolution because it's relative to the importing file
so your solution seems to me to be the ideal one
The ifs are useless though... just invoke both replace...they don't do anything when they don't match and the complexity
is the same... also calculate path.resolve(__dirname, 'app/javascript/shared/') once and store it outside of the loop
Hi,
I am trying to migrate from using Rails/webpacker to Rails/jsbundling/esbuild, and I have this particular issue with importMapper.
In our current
tsconfig.json
, we have path configured like the following.And in various
scss
files, we import them by stating and it works fine.Now with
esbuild
andesbuild-sass-plugin
, I have the following inesbuild.config.js
,But, when I run
yarn build
, I still get theCan't find stylesheet to import
error.But I do see the console log:
I feel like there is something obvious I am missing here. If you please point the obvious (or not so obvious) mistake(s), I would really appreciate it.
Thank you in advance!