It'd be nice to support config files with Babel syntax, e.g., as next.config.babel.js a la Webpack.
next.config.babel.js isn't picked up, and next.config.js doesn't seem to support syntax enabled by .babelrc.
next.config.js or try next.config.babel.js.
We are all used to modern JavaScript features when writing our JS. Some features would be especially useful, e.g., object spread operator.
| Tech | Version |
|---------|---------|
| next | 3.2.1 |
| node | 8.4.0 |
| OS | macOS Sierra 10.12.6 (16G29) |
| browser | Google Chrome 60.0.3112.113 (Official Build) (64-bit) |
Alot of people mentioned this trick:
//next.config.js
require('babel-register');
module.exports = require('./next.config.es6.js');
//next.config.es6.js
import blahblah...
Ideally you would want to compile ES6 with Babel beforehand.
There is currently no need to transpile the config file.
There is a real need in combination with static export. We are currently trying to fetch a list of blog posts from Contentful and add a route for each one of them to the staticExportMap. We already have a module abstracting Contentful that we use in our pages, but we cannot use it in next.config.js because it uses imports. So the only workaround is to change this module (and the modules it imports) to use require instead of import, which is really ugly.
@denisw I have exactly the same problem.
Also fetching data from contentful and generate dynamic pages with it.
Any insight on this would be helpful
The project I'm working on is private.
But I used similar config on my blog https://github.com/schoenwaldnils/blog
| Tech | Version |
|---------|---------|
| next | 5.0.1-canary-10 |
| node | 8.9.1 |
Most helpful comment
There is a real need in combination with static export. We are currently trying to fetch a list of blog posts from Contentful and add a route for each one of them to the
staticExportMap. We already have a module abstracting Contentful that we use in our pages, but we cannot use it innext.config.jsbecause it uses imports. So the only workaround is to change this module (and the modules it imports) to userequireinstead ofimport, which is really ugly.