简体   繁体   中英

Why is my next.config.js breaking my heroku build?

I am able to run the project locally, but ever since I changed next.config.js file to include @zeit/next-css my heroku build is failing and giving me the following error.

remote: Error: webpack build failed: found page without a React Component as default export in pages/gql/queries/age-ranges.js

And this is the content of my config file. The two commented out sections are other configurations I've tried that also failed.

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
            }
        }
    }
`;

Found the issue. Calendar picker CSS I imported was throwing an error but it was fixed when I updated Next to a more current version. But when I updated to the 'canary' version of next the build was failing because they require a different file structure.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM