I'm battling with a tricky SCSS import situation in my React project that's making me lose my mind.
My SCSS imports work perfectly in development, but when I build for production, it breaks because the nested imports aren't being detected by the watch process.
src/
styles/
main.scss
components/
_button.scss
variables/
_colors.scss
layout/
_grid.scss
@import './components/button';
@import './layout/grid';
// components/_button.scss
@import '../variables/colors'; // This import is being missed
Error: Can't find '../variables/colors' in components/_button.scss
at Object.<anonymous> (webpack:///./src/styles/main.scss?:1:1)
node_modules
and package-lock.json
You're using a relative path selection for the import.
Instead of using '../variables/' try using './variables/' with a single period like you have for your other imports.
Since you're in main.scss, when you use the relative path '../' it moves the folder lookup from styles/ to src/. And since there is no variables/ folder in src/, it throws the error.