Next.js - import css file does not work

后端 未结 6 756
北荒
北荒 2021-02-18 22:31

I am creating a project with react, redux and next.js, and want to import CSS files in js.

I followed instructions in next.js/#css and next-css, but find out that CSS st

6条回答
  •  清酒与你
    2021-02-18 23:03

    you need create to custom _document.js file.

    Custom document when adding css will look like:

    import React from "react";
    
    import Document, { Head, Main, NextScript } from "next/document";
    
    export default class MyDocument extends Document {
    
      render() {
        const { buildManifest } = this.props;
        const { css } = buildManifest;
        return (
          
            
              {css.map(file => (
                
              ))}
            
            
              
    ); } }

提交回复
热议问题