Flæx
Flæx

Reputation: 65

Importing external .js file to nuxt.config.js

I want to import config.js which includes project's API keys. But It returns undefined.

//config.js
var config = {
   fbAPI: "key"
}

-

//nuxt.config.js

const cfg = require('./config')
env: {
   fbAPI: cfg.apiKey
}

Is this problem about run-time or am I missing something?

Upvotes: 3

Views: 4985

Answers (1)

Pawel Zentala
Pawel Zentala

Reputation: 191

You missed modules.export at the end of config.js. The file should look following:

var config = {
   fbAPI: "key"
}

module.exports = config;

Upvotes: 4

Related Questions