What do I need to setup in brunch-config.js to be able to resolve absolute path from project's root folder? i.e
import { helper } from '/imports/utilities/helper'
The reason being is I have a legacy React app and it imports local files by using relative path. While I'm trying to use brunch, I need to figure out a way to setup brunch so that it understands the path without having to change the code.
I tried to use npm alias but not sure how it works
npm: {
aliases: {
'/imports': 'imports/**'
}
}
Found the solution with babel-plugin-module-resolver package.
Since all my codes are under
/importsdir, inbrunch-config.jsI setup an alias based on their documentation:That way, if I do
import Screen from '/imports/components/screens'it will resolve the file under./imports/components/screensYou can set the alias in
.babelrctoo but you might want to use regex instead.