Next.js production build is including all index.module.scss styles even when unauthenticated
Answered
Short mackerel posted this in #help-forum
Short mackerelOP
All of my pages/components are behind authentication with the exception of the login page.
When unauthenticated, the css file that is fetched in the production build includes all of the index.module.scss styling thats hidden behind authentication, even though none of those styles are used on the login page.
Some of the naming for these styles could provide information about what components are available behind authentication. Is the only way around this to obfuscate style names on build?
When unauthenticated, the css file that is fetched in the production build includes all of the index.module.scss styling thats hidden behind authentication, even though none of those styles are used on the login page.
Some of the naming for these styles could provide information about what components are available behind authentication. Is the only way around this to obfuscate style names on build?
Answered by Short mackerel
3 Replies
Philippine Crocodile
Are you doing just global imports? Eg
Or have you also done scoped imports? Eg
import "../styles/index.module.scss";Or have you also done scoped imports? Eg
import styles from "../styles/index.module.scss";Short mackerelOP
I have done scoped imports, in order to apply them to className. I wasn't aware it was possible to do global imports for scss modules.
Answer