-
카테고리
-
세부 분야
풀스택
-
해결 여부
미해결
next.config.js 설정 문제
21.08.05 15:18 작성 조회수 758
0
next.config.js 파일입니다.
.svg 등의 이미지 파일의 확장자가 필요하여 아래와 같이 설정하였습니다.
참조 사이트:
https://tomboy90.medium.com/next-js-url-loader-%EC%82%AC%EC%9A%A9-e2acf4898b7b
const withAssetsImport = require('next-assets-import');
module.exports = withAssetsImport({
urlLoaderOptions: {
rules: [
{
test: /\.(png|jpg|gif|mp4)$/i,
use: [
{
loader: 'url-loader',
options: {
limit: 8192,
},
},
],
},
],
},
});
여기에서
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
module.exports = withBundleAnalyzer({
distDir: '.next',
webpack(config, { webpack }) {
const prod = process.env.NODE_ENV === 'production';
const plugins = [
...config.plugins,
new webpack.ContextReplacementPlugin(/moment[/\\]locale$/, /^\.\/ko$/),
];
return {
...config,
mode: prod ? 'production' : 'development',
devtool: prod ? 'hidden-source-map' : 'eval',
plugins,
};
},
});
강의에서 알려주신 이것도 같이 적용하고싶은데, 여러 방법을 시도해봤으나 둘중에 하나만 적용이 되고있는 상태입니다.
어떤식으로 접근을 하면 좋을까요?
답변을 작성해보세요.
2
조현영
지식공유자2021.08.05
https://www.npmjs.com/package/next-compose-plugins
위 라이브러리를 사용해서 적용하는게 깔끔합니다. 안 그러면 with안에 with안에 with가 들어가는 구조가 되어버립니다.
0
답변 2