我正在使用react和next js。我在next.config文件中添加了@ zeit / next-css和@ zeit / next-sass。
const withSass = require('@zeit/next-sass');
const withCSS = require('@zeit/next-css');
module.exports = withCSS(withSass());
现在我也想加载文件。我尝试执行此操作但不起作用并出现错误:
module.exports = withCSS(withSass({
webpack (config, options) {
config.module.rules.push({
test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
use: {
loader: 'url-loader',
options: {
limit: 100000
}
}
});
return config;
}
}));
_app.js:7 Uncaught Error: A cross-origin error was thrown. React doesn't have access to the actual error object in development.
我也安装了next-images,但是我不知道如何用css和sass对其进行配置?
const withSass = require('@zeit/next-sass');
const withCSS = require('@zeit/next-css');
const withImages = require('next-images');
module.exports = withCSS(withSass(withImages ()));//error and not working
答案 0 :(得分:3)
您可以尝试这样。 next-compose-plugins可以解决问题。
const withPlugins = require('next-compose-plugins');
const withCSS = require("@zeit/next-css");
const withSass = require('@zeit/next-sass');
const withImages = require('next-images');
module.exports = withPlugins([
[
withCSS(withSass({}))
],
[
withImages({})
],
])