In the past days I have kind of a headache with this and it's surely due to my lack of experience. I recently started using nuxt
and nuxt
modules.
As I use the command yarn create nuxt-app my-project
, the nuxt.config.js
file is populated with module.exports
. My problem is that when I was installing certain modules, the configuration was only working in export default
. I have for example the following config:
build: {
extend (config, { isDev, isClient }) {
if (isDev && isClient) {
config.module.rules.push({
enforce: 'pre',
test: /\.(js|vue)$/,
loader: 'eslint-loader',
exclude: /(node_modules)/
})
}
}
}
This configuration only works inside export default
but not when I write it in module.exports
, I have no clue about the reason.
Another example is with head
, let's say the following code:
head: {
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.png' }
]
},
When I put it in export default
, it doesn't work, and in module.exports
it works. So, until now I'm doing trial and error depending where it works.
I know that there is a reference in the question module.exports vs. export default in Node.js and ES6 . However it's not yet clear to me why some stuff work in module.exports
and some other stuff in export default
.
Some explanation would be highly appreciated.