Global CSS not applied to AMP pages
See original GitHub issueBug report
Describe the bug
Global CSS (via _app.tsx/_app.js) are not being applied to AMP pages.
Non-AMP pages do not have this issue.
To Reproduce
Reproduction sandbox: https://github.com/achrinza/issue-sandbox-nexjs-global-css-amp
Step-by-step:
- Run
npm init next-app - Create
styles.cssbody { color: #f00; } - Create
pages/_app.jsimport '../styles.css'; export default ({ Component, pageProps }) => ( <Component {...pageProps} /> ); - Create
pages/NonAmp.jspage:const NonAmp = () => ( <p>Hello, world!</p> ); export default NonAmp; - Create
pages/Amp.jspageexport const config = { amp: true } const Amp = () => ( <p>Hello, world!</p> ); export default Amp; - Run
npm run dev - View
localhost:3000/Ampandlocalhost:3000/NonAmp- observe the lack ofcolor: redon the AMP page.
Expected behavior
The AMP page should have a global CSS applied.
Screenshots
If applicable, add screenshots to help explain your problem.
System information
- OS: Windows 10
- Firefox 73.0
- Version of Next.js: 9.2.1
Additional context
N/A
Issue Analytics
- State:
- Created 4 years ago
- Reactions:52
- Comments:40 (5 by maintainers)
Top Results From Across the Web
Nextjs - Global.css style not applying/working on pages ...
hi, I found out that the css class in global.css ( example: section-sidebar-filter-name ) is now in this format [folder]__section-sidebar-filter ...
Read more >CSS not visible in AMP Pages | WordPress.org
Hello, I am facing trouble with the AMP pages. On the main page, I have used the Download and Purchase button see here,...
Read more >Supported CSS - amp.dev
Like all web pages, AMP pages are styled with CSS, but you can't reference external stylesheets (with the exception of custom fonts).
Read more >Basic Features: Built-in CSS Support - Next.js
These styles ( styles.css ) will apply to all pages and components in your application. Due to the global nature of stylesheets, and...
Read more >Three reasons you might not need Google AMP after all
To get started with this, set your website code to reference an external CSS file called from your CDN, rather than placing the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

It’s a really big issue because I use tailwind and I need style AMP pages with tailwindcss classes.
@timneutkens You are the guy I was trying to reach out. I have few related questions. Please let me know if I should create new issue for any of them.
Is it better to write amp pages with
jsxor is it better with.md?The benefit of using
.mdis the front matter(date or cateogory) that I can use to sort blog post and generate blog list pages.How would someone go about automatically generating list pages from
amppage written injsx? or add front matter tojsxpage? Ideally I would like to keep front matter, images and other static assets and the actual blog post right next to each other. Because all of these are static.How good is
.mdtoamppage conversion? I am usingmarked(as per documentation) to convert.mdtohtml, adding dangerous inner html and makingexport config = { amp: true }and hoping that nextjs will do the rest. Like importing relevant amp libraries.How to add
disquscomments foramppages/blog posts in Next js?My preference has changed from
.mdtojsx. Because I can use reusable components withjsx. This is complicated and time consuming to do with.md. I have literally learned about Nextjs 4 days ago. So I am trying things out and figuring out what I like. FYI when I sayjsxthen I actually meantsx. But that shouldn’t matter.How do I pull title, description, categories, date from 100’s of
jsxfiles to build list page?Also I was able to replicate
SASS mixinswithjsvariables. Only thing I miss fromSASSis nestingcss. Currently I have to write full formcss.