Dynamic import and imported css on the page
Unanswered
Brewer's Blackbird posted this in #help-forum
Brewer's BlackbirdOP
Hello everyone! I am really concerned about optimizing my project. I would like the modular styles that I used in my component to be imported to the current page only if it is on the page. i.e. to use styles only from those components that I used on the page.
This can be achieved using dynamic import, but there is a problem. From the backend, I have components as types, I go through these components in a cycle and, depending on what comes from the backend, I display the order and a specific component in the cycle passed. Naturally, I have a file with combinations (correspondences) of the type of component (section) that comes from the backend and the component itself.
but since all components are dynamically imported into a single array, all styles of these components imported too.
is it possible to somehow solve this problem?
This can be achieved using dynamic import, but there is a problem. From the backend, I have components as types, I go through these components in a cycle and, depending on what comes from the backend, I display the order and a specific component in the cycle passed. Naturally, I have a file with combinations (correspondences) of the type of component (section) that comes from the backend and the component itself.
but since all components are dynamically imported into a single array, all styles of these components imported too.
is it possible to somehow solve this problem?
1 Reply
Brewer's BlackbirdOP
Using nextjs 15