I am very lost.
For context, I am using Next and React.
// package.json
"dependencies": {
"@netlify/plugin-nextjs": "^3.4.2",
"next": "^10.0.0",
"postcss-flexbugs-fixes": "^5.0.2",
"postcss-preset-env": "^6.7.0",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-onclickoutside": "^6.11.2",
"react-svg": "14.0.0"
},
"devDependencies": {
"classnames": "^2.2.6",
"sass": "^1.34.0"
}
I use npx next build && npx next start -p 4000 to test production locally. It all works fine in dev using netlify dev -e.
There are weird effects. When I have two imports of .module.scss, the client-side javascript just stops.
I have a page:
// /pages/test.js
import CompA from 'components/comp-a'
import CompB from 'components/comp-b'
And:
// /components/comp-a.js
import styles from 'components/comp-a.module.scss`
and
// /components/comp-b.js
import styles from 'components/comp-b.module.scss`
This situation renders correctly visually but NO client-side javascript is working at all and, of course, without any error. I spent the day commenting and uncommenting each component and line of my source code to narrow down to this situation.
I tried by commenting out in the page, with one component the client-side js works, not with two.
I tried commenting out the styles import in one of the components, the client-side js works as well.
Another situation where it does not work is :
// components/comp-a.js
import styles from 'components/comp-a.module.js'
import CompB from 'components/comp-b.module.js'
and it works if I comment either one of the style or the sub component.
And none of it makes sense because in the page, I also have the Layout being imported that does contain its own styles and that works fine.
What is going on ???
Edit:
Continuing to dig, I found out that I was doing @extend .class-abc and at the top @import 'style/foo.module'; , and the .class-abc was containing an other class:
// /style/foo.module.scss
.class-abc {
...
.bar {
...
}
}
For some reason, commenting out .bar solve the problem. No idea what is going on.