我正在使用两个库(react-image-crop和react-responsive-carousel),每个库都需要一个 css 导入。我已将 css 加载器添加到next.config.js页面最初加载时,一切都很好。但是,在页面上调用刷新时会出现document is not defined错误。此外,当我yarn build按预期运行构建时,最后会以 a 失败Reference Error并引用此document is not defined错误。
任何帮助都会很棒。
next.config.js
...
const REACT_CAROUSEL_PATH = path.resolve(__dirname, './node_modules/react-responsive-carousel');
const REACT_IMAGE_CROP_PATH = path.resolve(__dirname, './node_modules/react-image-crop');
...
config.module.rules.push({
test: /\.css$/i,
include: [REACT_CAROUSEL_PATH, REACT_IMAGE_CROP_PATH],
use: [{
loader: 'style-loader'
},
{
loader: 'css-loader'
}],
})