Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LESS in _document.js renders perfectly in DEV but is missing in PRODUCTION #4905

Closed
aofolts opened this issue Aug 6, 2018 · 2 comments
Closed

Comments

@aofolts
Copy link

aofolts commented Aug 6, 2018

Bug report

Describe the bug

When I import a LESS file in _document.js, it renders using run dev, but when I build and use run start, the style from global.less is not rendered.

LESS files seem to render properly everywhere BUT _document.js.

To Reproduce

npm run dev
global.less in _document.js is rendered properly.

npm run start
global.less in _document.js is not rendered.

import '../src/less/global.less'

export default class Template extends Document {

  static async getInitialProps(ctx) {
    const initialProps = await Document.getInitialProps(ctx)
    return { ...initialProps }
  }

  render() {
    return (
      <html lang='en_US'>
        <Head>
          <link rel="stylesheet" href="/_next/static/style.css" />
          <Typekit kitId='dxm1wgv'/>
        </Head>
        <body className="custom_class">
          <Main />
          <NextScript />
        </body>
      </html>
    )
  }
}

Expected behavior

LESS files used in _document.js should render in DEV and PRODUCTION.

System information

  • OS: macOS
  • Browser: Chrome 68
  • Version of Next.js: 6.1.1
@aofolts
Copy link
Author

aofolts commented Aug 6, 2018

I moved my global LESS to a Layout component, and it rendered just, so I don't know why _document.js wouldn't work, but I guess it doesn't matter!

@aofolts aofolts closed this as completed Aug 6, 2018
@timneutkens
Copy link
Member

_document should't be used for anything other than html structure / css-in-js. Instead use _app.js for your business logic (css etc)

@lock lock bot locked as resolved and limited conversation to collaborators Aug 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants