When using styled-components
in Next with React, it can become challenging to ensure that the styled components render correctly. To address this issue, Next supplies the compiler.styledComponents
flag
in next.config.js
as follows:
compiler: {
styledComponents: true
}
However, when this flag is enabled, it leads to the class names becoming unreadable as they increase in size exponentially.
The following images illustrate the difference in class names between when compiler.styledComponents
is disabled and when it is enabled.
When compiler.styledComponents
is not set:
When compiler.styledComponents
is set:
Is there a way to reduce the class name sizes to just their regular sc-XXXXXX
names?
I should note that we're not using the latest version of Next, but instead [email protected]