这是我们的next.config.js文件
const webpack = require('webpack');
// Initialize doteenv library
require('dotenv').config();
module.exports = {
swcMinify: true,
devIndicators: {
autoPrerender: false,
},
compiler: {
styledComponents: true, // ssr and displayName are configured by default
removeConsole: true,
},
webpack: (config) => {
config.plugins.push(new webpack.EnvironmentPlugin(process.env));
config.module.rules.push({
test: /\.svg$/,
issuer: {
and: [/\.(js|ts)x?$/],
},
use: ['@svgr/webpack'],
});
return config;
},
eslint: {
// Warning: Dangerously allow production builds to successfully complete even if
// your project has ESLint errors.
// but we are running eslint separately, therefore no need to worry about disabling
// ESLint on next build
ignoreDuringBuilds: true,
},
}
生成时出现此错误/警告
DefinePlugin
Conflicting values for 'process.env.NEXT_RUNTIME'
当我尝试console.log时,将NEXT_RUNTIME: 'nodejs'
作为process.env.NEXT_RUNTIME的值
我们使用SWC作为编译器,而不是Babel。有什么办法可以解决这个问题吗?
1条答案
按热度按时间sbdsn5lh1#
将
EnvironmentLogin
替换为DefinePlugin
为我修复了警告。我希望这能帮上忙🤞