Next.js dotenv 적용방법

2ERO·2022년 10월 20일
0

인터넷에 있는 방법대로 yarn add dotenv cross-env 해봤는데 안되서
좀 더 검색해보니까 dotenv-webpack이 설치되어야 하고
next.config.js에서 dotenv-webpack를 한번 더 추가해서 불러와줘야한다.

const Dotenv = require('dotenv-webpack')

///
webpack: (config, { isServer }) => {
if (!isServer) {
config.resolve.fallback = {
fs: false,
};
}
config.plugins.push(new Dotenv({ silent: true }));

return config;

},
///

fs모듈을 불러오지 못하는 이슈가 있어 추가해준다.

profile
이것저것 간단하게 적어놓는 블로그

0개의 댓글