简体   繁体   English

带有Sass的Next.js发生错误,提示“您可能需要适当的加载程序来处理此文件类型错误”

[英]Next.js with Sass occurs on error saying “ You may need an appropriate loader to handle this file type error”

I tried to several times to wire up my next.js and scss but it does not work. 我试图几次连接next.js和scss,但是它不起作用。

I thought I set up everything to compile my file with scss. 我以为我设置了一切,用scss编译我的文件。

The error saying that 错误说

/scss/style.scss 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type.
> .example {
|   color: blue;
| }

here is the code : 这是代码:

next.config.js next.config.js

const withSass = require("@zeit/next-sass");
module.exports = withSass();

_document.js _document.js

import Document, { Head, Main, NextScript } from "next/document";

export default class extends Document {
  render() {
    return (
      <html>
        <Head>

        <link rel="stylesheet" href="/_next/static/style.css" />
        <Head />
        <body>
          <Main />
          <div id="modal" />
          <NextScript />
        </body>
      </html>
    );
  }
}

index.js index.js

import "../scss/style.scss";

import axios from "axios";

const Index = props => {
  return (
    <div>
      <div className="example">hello</div>
      <header>
        <Header />
      </header>
      <section>
        <Body stores={props.data} />
      </section>
      <footer>
        <Footer />
      </footer>
    </div>
  );
};

style.scss in SCSS folder SCSS文件夹中的style.scss

.example {
  color: blue;
}

try to add import "../scss/style.scss"; 尝试添加import "../scss/style.scss"; to your _document.js . _document.js

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 你可能需要一个合适的加载器来处理 ReactJS 文件中发生的这种文件类型错误 - You may need an appropriate loader to handle this file type error occurs in ReactJS file 您可能需要适当的加载程序来处理此文件类型错误 - You may need an appropriate loader to handle this file type-error webpack错误-您可能需要适当的加载程序来处理此文件类型 - error with webpack - You may need an appropriate loader to handle this file type glsify - 错误'您可能需要适当的加载程序来处理此文件类型'? - glsify - error 'You may need an appropriate loader to handle this file type'? Webpack错误:“您可能需要适当的加载程序来处理此文件类型” - Webpack error: “You may need an appropriate loader to handle this file type” ReactJS 错误您可能需要适当的加载程序来处理此文件类型 - ReactJS error You may need an appropriate loader to handle this file type 错误:您可能需要适当的加载程序来处理此文件类型 - Fusion Js,使用图标 - Error: You may need an appropriate loader to handle this file type - Fusion Js, with using icons Chart.js 错误:您可能需要适当的加载程序来处理此文件类型 - Chart.js Error: You may need an appropriate loader to handle this file type 你可能需要一个合适的加载器来处理这种文件类型的 js - You may need an appropriate loader to handle this file type js js错误:您可能需要适当的加载器 - js error: You may need an appropriate loader
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM