css - 如何组合和使用多个 Next.js 插件
问题描述
我想在应用程序中使用css
和。scss
next.js
我next.config.js
在我的项目中有。
此配置适用于scss
:
// next.config.js
const withSass = require('@zeit/next-sass');
module.exports = withSass({
cssModules: true,
cssLoaderOptions: {
importLoaders: 1,
localIdentName: "[local]___[hash:base64:5]",
}
})
我不知道如何const withCSS = require('@zeit/next-css');
与我当前的配置相结合。
我想使用自定义配置scss
(来自我的代码片段)。
有人可以帮我配置下一个css
和scss
模块吗?
我试过了:
// // next.config.js
const withSass = require('@zeit/next-sass');
const withCSS = require('@zeit/next-css');
module.exports = withCSS(withSass({
cssModules: true,
cssLoaderOptions: {
importLoaders: 1,
localIdentName: "[local]___[hash:base64:5]",
}
}))
不工作...
解决方案
您可以使用next-compose-plugins
和组合多个 next.js 插件,如下所示:
// next.config.js
const withPlugins = require('next-compose-plugins');
const withSass = require('@zeit/next-sass');
const withCSS = require('@zeit/next-css');
module.exports = withPlugins(
[
[withSass, { /* plugin config here ... */ }],
[withCSS, { /* plugin config here ... */ }],
],
{
/* global config here ... */
},
);
推荐阅读
- python - 如何在张量的特定索引处打印值
- html - 在导航栏中排列标题
- ruby-on-rails - 机架攻击阻止列表不起作用
- sql - 仅获取列中的数字
- modelsim - 如何更改显示波浪的默认颜色
- javascript - HTML5 Canvas 中的动画后图像变暗
- asp.net-identity - 如何一起使用 Core ASP.Net Identity、负载均衡器和 Identity.External?
- android - 在onError之后ReactiveX PublishProcessor不执行onNext?
- ios - 映射包含错误的 SignalProducer 以返回 NoError
- javascript - 分配事件处理程序时未定义文档