javascript - 为什么我的 next.config.js 会破坏我的 heroku 构建?
问题描述
我可以在本地运行该项目,但是自从我更改next.config.js
文件以包含@zeit/next-css
我的 heroku 构建失败并给我以下错误。
remote: Error: webpack build failed: found page without a React Component as default export in pages/gql/queries/age-ranges.js
这是我的配置文件的内容。两个注释掉的部分是我尝试过的其他配置也失败了。
next.config.js
const withImages = require('next-images');
const withCSS = require('@zeit/next-css');
module.exports = withCSS(withImages());
// ---- -----
// const withPlugins = require('next-compose-plugins');
// const withCSS = require('@zeit/next-css');
// const withImages = require('next-images');
// const nextConfig = {
// useFileSystemPublicRoutes: false,
// webpack: config => {
// config.node = {
// fs: 'empty',
// modules: false
// };
// return config;
// }
// };
// module.exports = withPlugins([withCSS, withImages], nextConfig);
// ----- synapse -----
// const withCSS = require('@zeit/next-css');
// const withImages = require('next-images');
// module.exports = withCSS(withImages());
// module.exports = withCSS(
// withImages({
// target: 'serverless',
// webpack(config) {
// config.module.rules.push({
// test: /\.(png|svg|eot|otf|ttf|woff|woff2)$/,
// use: {
// loader: 'url-loader',
// options: {
// limit: 8192,
// publicPath: '/_next/static/',
// outputPath: 'static/',
// name: '[name].[ext]'
// }
// }
// });
// return config;
// }
// })
// );
/gql/queries/age-ranges.js
import gql from 'graphql-tag';
export const GET_AGE_RANGES = gql`
query getAgeRanges {
allAgeRanges {
nodes {
name
nodeId
id
}
}
}
`;
解决方案
发现问题。我导入的日历选择器 CSS 引发了错误,但当我将 Next 更新到更当前的版本时,它已得到修复。但是当我更新到 next 的“金丝雀”版本时,构建失败了,因为它们需要不同的文件结构。
推荐阅读
- oracle - 是否可以在过程中将数组作为参数传递?
- r - 在 R 中使用带有循环的其他变量名创建新变量
- c++ - 如何使用值获取结构的索引
- ruby-on-rails - Ruby on Rails:对两个字段使用关联?
- r - 在R中将数据帧拆分为n组数据帧的函数
- react-native - react-native-testing-library:如何使用 act 测试 useEffect
- c# - 使用 C# SharpADBClient 将设备信息输出到文本框在设备连接上重复文本
- cmake - 如何获取 CMake 项目的输出路径?
- apache-drill - 如何在apache钻查询where子句中使用算术运算符?
- ruby-on-rails - 在 Heroku 上使用 Resque 不能从事后台工作