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
When styles are added using local css files on client:only="react" components, styles don't get loaded into the page when building the page and using preview npm run build && npm run preview which more or less replicates my production deployment situation, using an S3 bucket and CloudFront on AWS. This doesn't affect other client: directives nor does it when using they "styles" prop on the html component or tailwind classes. This just happens when css files are being imported on cliend:only="react" components (not sure about other integrations though),
importReactfrom'react'importstylesfrom'./styles.module.css'// also happens when using styles.csstypeProps={}constCoolComponent=(props: Props)=>{return(<div><h1>Cool Component</h1><divclassName={styles.first}><divclassName={styles.second}></div></div></div>)}exportdefaultCoolComponent
and I am importing it on the index page
---importLayoutfrom"../layouts/Layout.astro";importCoolComponentfrom"../components/CoolComponent";---
<Layouttitle="Welcome to Astro.">
<CoolComponentclient:only="react" />
</Layout>
Since I'm using SSG, and the uploading it to an S3 Bucket I need to run npm run build and then I upload all the files to the bucket
I notice that there is a file that contains the css styles for Cool Component
But on the actual page that file never gets imported
Note: I just realised that I can replicate this bug result using npm run preview that way I don't need to upload it to an s3 bucket.
I am willing to submit a pull request for this issue.
The text was updated successfully, but these errors were encountered:
davidvpe
changed the title
Astro generated css classes don't exist when using client:only=react
file.module.css classes don't get loaded on SSG build when using client:only=react
Oct 22, 2022
davidvpe
changed the title
file.module.css classes don't get loaded on SSG build when using client:only=react
imported css file classes don't get loaded on SSG build when using client:only=react
Oct 22, 2022
What version of
astro
are you using?1.5.2
Are you using an SSR adapter? If so, which one?
None, just SSG
What package manager are you using?
npm v8.15.0 & node v16.17.0
What operating system are you using?
macOS Monterrey 12.6
Describe the Bug
When styles are added using local css files on client:only="react" components, styles don't get loaded into the page when building the page and using preview
npm run build && npm run preview
which more or less replicates my production deployment situation, using an S3 bucket and CloudFront on AWS. This doesn't affect other client: directives nor does it when using they "styles" prop on the html component or tailwind classes. This just happens when css files are being imported on cliend:only="react" components (not sure about other integrations though),These are the steps to reproduce:
I've created a react component
CoolComponent.tsx
and I am importing it on the index page
Since I'm using SSG, and the uploading it to an S3 Bucket I need to run
npm run build
and then I upload all the files to the bucketI notice that there is a file that contains the css styles for Cool Component
But on the actual page that file never gets imported
Note: I just realised that I can replicate this bug result using
npm run preview
that way I don't need to upload it to an s3 bucket.Expected result:
Actual result:
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-zm1d9c?file=src/pages/index.astro
Participation
The text was updated successfully, but these errors were encountered: