我正在尝试使用sass-resources-loader使我的SASS变量在我的所有SASS文件中都可用,但是看起来该加载程序无法使用SASS。
next-sass软件包文档建议您可以包装config对象,以使sass可用。例如withSass({configHere})。
但是我收到的错误提示SASS加载程序不可用。
配置:
Activity
我收到此错误:
const path = require('path');
const withSass = require('
@zeit
/next-sass');
const globalSass = [
path.join(process.cwd(), 'stylesheets/variables/_variables.scss'),
path.join(process.cwd(), 'stylesheets/tools/_tools.scss')
]
module.exports = withSass({
webpack: (config, { buildId, dev, isServer, defaultLoaders }) => {
// Perform customizations to webpack config
// Important: return the modified config
config.module.rules.push({
loader: "sass-resources-loader",
options: {
resources: globalSass
}
})
return config
}
})
其中$ font-size-base等位于“ sass-resources-loader”处理的变量SASS文件中。
有人可以建议我在这里做错什么吗?
答案 0 :(得分:2)
我有几点建议。
您没有规则的测试:
B b = new B("hello");
System.out.println(b.a); // hello
System.out.println(((A) b).a); // hello
您可能还需要使用以下方法来强制 sass-resources-loader 首先运行,然后再运行其他加载程序:
test: /\.scss$/
因此,请尝试以下配置:
enforce: 'pre'
希望这对您有用。