I have have a file "style.scss" and I want to import it to _doucment.js file to add it to the Header there and use it across all pages , I am using
import "./syles.css
this approch works in the components very well , but it is not working in _document.js . I have read some solutions for issues related to this,and I tried but it didn't work ,I think the answer is simple but I am still able to figure out how ? ! thanks in advance for help
any information please?
@JSMindBlowing I put my global styles in a custom _app.js
@jbsmith731 thanks for replying.. can you provide the way how you implement it please?
@JSMindBlowing This is a simplified version of what I do. I use css modules so that's where import s from 'style.scss' & s.Layout comes from.
import React from 'react'
import App, { Container } from 'next/app'
import s from 'style.scss'
export default class MyApp extends App {
static async getInitialProps({ Component, router, ctx }) {
let pageProps = {}
if (Component.getInitialProps) {
pageProps = await Component.getInitialProps(ctx)
}
return { pageProps }
}
render () {
const { Component, pageProps } = this.props
return (
<Container>
<div className={s.Layout}>
<Component {...pageProps} />
</div>
</Container>
)
}
}
@jbsmith731 , it works , thank you very much , now I can go party :D
Most helpful comment
@jbsmith731 , it works , thank you very much , now I can go party :D