gpt4 book ai didi

Gatsby SCSS 模块未编译

转载 作者:行者123 更新时间:2023-12-04 03:38:28 24 4
gpt4 key购买 nike

使用 sass 1.32.8 运行 Gatsby 版本 3.0.1。我刚刚开始玩一些事情,我遇到了一个我无法解决的奇怪问题。./gatsby-config.js

module.exports = {
/* Your site config here */
plugins: [
{
resolve: `gatsby-plugin-sass`,
options: {
implementation: require("sass"),
},
},
],
}
./src/pages/index.js
import React from "react"
import homeStyles from '../styles/scss/index.module.scss'

export default function Home() {
return <div className={homeStyles.testElement}>Hello world!</div>
}
./styles/scss/index.module.scss
.testElement {
font-size: 72px;
}
我得到的错误是 Attempted import error: '../styles/scss/index.module.scss' does not contain a default export (imported as 'homeStyles').如果我尝试使用 import * as homeStyles from '../styles/scss/index/module.scss错误是: Attempted import error: 'testElement' is not exported from '../styles/scss/index.module.scss' (imported as 'homeStyles').在不确切知道插件如何工作的情况下,我看不到任何可能导致此问题的问题。

最佳答案

像这样使用它:

module.exports = {
/* Your site config here */
plugins: [
{
resolve: `gatsby-plugin-sass`,
},
],
}
你不需要添加额外的实现来使用 CSS 模块,所以你可以省略它们。
另外,据此 GitHub thread解决方案是将插件降级为 v4 .

关于Gatsby SCSS 模块未编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66493108/

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