[英]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.