mingg IT

[Next.js] Next.js 에서 .module.scss 사용하기 본문

FrontEnd

[Next.js] Next.js 에서 .module.scss 사용하기

mingg123 2022. 3. 8. 14:49

기본 CRA로 만들어진 페이지를 Next.js로 마이그레이션 하는 과정에서 .module.scss 사용 에러가 났다. 

 

yarn 으로 설치 하자 

yarn add @zeit/next-sass node-sass  

next.config.js 를 수정해준다. 

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  cssModules: true,
};

const withSass = require('@zeit/next-sass');
module.exports = withSass;
module.exports = nextConfig;

 

next.config.js를 수정해주었으니 yarn dev 한번 하고나면 module.scss가 정상적으로 작동하는걸 확인할 수 있음. 

Comments