You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My setup is as follows: one index.html, react-router that shows either an overview page or one of three ‘subpages’ (=features of my app). Every subpage has its own styles.css file and uses some general purpose components, which also each have their own styles.css file.
The subpages are included via React.lazy so that js/css resources are only loaded when a user actually navigates to the page.
When building the app, the css-styles for the ‘general purpose’ components and for one feature/subpage are placed in the same css file (can be seen in the sample repo below). This means when I navigate between different subpages:
The css styles for the first subpage, which also includes the common styles has to be loaded (going to featureA requires us to load the css styles for featureC). Not pretty, but I can live with that.
the order of declaration of the components in my main source file (App.tsx) is relevant: most css is included in along the subpage that is listed as first component in App.tsx. If I change the order and put another component first, that one now gets a larger css file with unrelated styles in it.
The file that contains the common styles is inserted into the head whenever I visit a feature for the first time. So if I visit three features/subpages, the same file is loaded three times.
The look of my components changes, because later loaded ‘common styles’ now take precedence over earlier included styles that were specific for just one subpage/feature.
🤔 Expected Behavior
Ideally, the css for my shared components (that are used on several pages) would be bundled into a separate 'index.css' file on top level, or their own 'MyComponent.css' file - rather than into the css file for some random subpage.
Another thing that would solve the issue for me would be a way to disable cache busting (appending a timestamp in the request to a resource) in serve mode. If I didn’t have that, the splitting of css would still be weird, but at least the colors would not change mid-navigation.
💁 Possible Solution
🔦 Context
I'm updating a much larger application from parcel1 to parcel2. For a production build everything looks ok, but for the dev setup with HMR, the app layout breaks after a few clicks because of css files being loaded multiple times.
The README.md file gives instructions on how to run it and reproduce my issue, also with more screenshots and detailed analysis which classes are assigned to which component.
🌍 Your Environment
Software
Version(s)
Parcel
2.9.3
Node
16.14.2
npm/Yarn
8.5.0
Operating System
MacOS 12.3.1
The text was updated successfully, but these errors were encountered:
cernychristopher
changed the title
css file is included multiple times in <head>
css file is included multiple times in <head> (when using parcel serve)
Sep 27, 2023
🐛 bug report
I am facing a problem with serving css for an app built with parcel. The same css file is included multiple times into the
<head>
of the page.(in this case:
FeatureC.2a93835a.css
)🎛 Configuration (.babelrc, package.json, cli command)
My setup is as follows: one index.html, react-router that shows either an overview page or one of three ‘subpages’ (=features of my app). Every subpage has its own styles.css file and uses some general purpose components, which also each have their own styles.css file.
The subpages are included via
React.lazy
so that js/css resources are only loaded when a user actually navigates to the page.parcel serve ./src/index.html --no-cache --dist-dir ./dist
😯 Current Behavior
When building the app, the css-styles for the ‘general purpose’ components and for one feature/subpage are placed in the same css file (can be seen in the sample repo below). This means when I navigate between different subpages:
🤔 Expected Behavior
Ideally, the css for my shared components (that are used on several pages) would be bundled into a separate 'index.css' file on top level, or their own 'MyComponent.css' file - rather than into the css file for some random subpage.
Another thing that would solve the issue for me would be a way to disable cache busting (appending a timestamp in the request to a resource) in serve mode. If I didn’t have that, the splitting of css would still be weird, but at least the colors would not change mid-navigation.
💁 Possible Solution
🔦 Context
I'm updating a much larger application from parcel1 to parcel2. For a production build everything looks ok, but for the dev setup with HMR, the app layout breaks after a few clicks because of css files being loaded multiple times.
💻 Code Sample
https://github.com/cernychristopher/parcel2cssoverwrite/tree/main#the-issue
The README.md file gives instructions on how to run it and reproduce my issue, also with more screenshots and detailed analysis which classes are assigned to which component.
🌍 Your Environment
The text was updated successfully, but these errors were encountered: