fav*_*149 18 css sass reactjs next.js
我想在应用程序中使用css和。scssnext.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]",
}
})
Run Code Online (Sandbox Code Playgroud)
我不知道如何结合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]",
}
}))
Run Code Online (Sandbox Code Playgroud)
不工作...
ElD*_*n90 29
您可以使用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 ... */
},
);
Run Code Online (Sandbox Code Playgroud)
Ben*_*ing 18
即使没有库,这也可以很容易地完成next-compose-plugins。
可以说也更清楚了:
// next.config.js
const withSass = require('@zeit/next-sass');
const withCSS = require('@zeit/next-css');
module.exports = (phase, { defaultConfig }) => {
const plugins = [
withSass({ /* Plugin config here ... */ }),
withCSS({ /* Plugin config here ... */ }),
];
return plugins.reduce((acc, next) => next(acc), {
/* global config here ... */
});
};
Run Code Online (Sandbox Code Playgroud)
我在这里抱怨时发现了这一点:来源
| 归档时间: |
|
| 查看次数: |
7280 次 |
| 最近记录: |