文章教程
https://github.com/zeit/next-plugins/tree/master/packages/next-sass
安装
npm install --save @zeit/next-sass node-sass
配置文件使用cssModules
// next.config.js
const withSass = require('@zeit/next-sass')
module.exports = withSass({
cssModules: true
})
在页面中使用
import css from "./layout.scss"
...
<Link href='/'><div className={css.nav}>Home</div></Link>
Note:
在自定义组件上使用class加样式是不起作用的,比如在上边的Link上加上className