Front-End
[Next.js] Next에서 config 설정
by Judy
2022. 3. 18.
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
const withPlugins = require('next-compose-plugins');
const withAntdLess = require('next-plugin-antd-less');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const withAntdLessConfig = {
modifyVars: { '@primary-color': '#348fe2' },
lessVarsFilePath: './pages/antd-custom.less',
lessVarsFilePathAppendToEndOfContent: false,
cssLoaderOptions: {},
future: {
webpack5: true,
},
};
const plugins = [
[withAntdLess, withAntdLessConfig],
];
const nextConfig = {
webpack: (config, { webpack }) => {
const prod = process.env.NODE_ENV === 'production';
const newConfig = {
...config,
mode: prod ? 'production' : 'development',
};
if (prod) {
newConfig.devtool = 'hidden-source-map';
}
return newConfig;
},
async rewrites() {
return [
{
source: '/:path*',
destination: `${process.env.NEXT_PUBLIC_API_URL}/:path*`,
},
];
},
};
module.exports = withPlugins(plugins, nextConfig);
module.exports = {
reactStrictMode: true,
}
NODE_ENV="development"
ENV_LOCAL_VARIABLE="server_only_variable_from_env_local"
NEXT_PUBLIC_ENV_LOCAL_VARIABLE="public_variable_from_env_local"
NEXT_PUBLIC_API_URL="http://dev.api2.test.co.kr"
NEXT_PUBLIC_IMAGE_URL="https://test.co.kr/web/images"