Home

Issue: 2885

How to allow ES6 imports in nuxt.config.js file?

[issue link]

I want to grab some data from a config file to use in nuxt.config.js, but it comes up with the SyntaxError: Unexpected token import error.

/assets/site-config.js (used throughout components as well)

export default {}

nuxt.config.js

import SITE from './assets/site-config'
module.exports = {}

I’ve tried to create a .babelrc to transform the imports to commonjs but it doesn’t work.

.babelrc:

{
  "plugins": ["transform-es2015-modules-commonjs"]
}
This feature request is available on Nuxt.js community (#c2507)