gpt4 book ai didi

javascript - Next.js 与 Sass 发生错误说 "You may need an appropriate loader to handle this file type error"

转载 作者:行者123 更新时间:2023-11-28 19:31:40 24 4
gpt4 key购买 nike

我多次尝试连接我的 next.js 和 scss,但它不起作用。

我想我已经设置好一切以使用 scss 编译我的文件。

错误说

/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;
| }

代码如下:

next.config.js

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

_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

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 在 SCSS 文件夹中

.example {
color: blue;
}

最佳答案

尝试将 import "../scss/style.scss"; 添加到您的 _document.js

关于javascript - Next.js 与 Sass 发生错误说 "You may need an appropriate loader to handle this file type error",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54882223/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com