首页 > 解决方案 > 为什么我的 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
            }
        }
    }
`;

标签: javascriptnode.jsherokuwebpacknext.js

解决方案


发现问题。我导入的日历选择器 CSS 引发了错误,但当我将 Next 更新到更当前的版本时,它已得到修复。但是当我更新到 next 的“金丝雀”版本时,构建失败了,因为它们需要不同的文件结构。


推荐阅读