Lately, I've been struggling with a headache because of my lack of experience in using nuxt
and its modules. After running the command yarn create nuxt-app my-project
, the nuxt.config.js
file is filled with module.exports
. However, I've encountered issues where certain module configurations only work when placed inside export default
. An example of this is the build configuration:
build: {
extend (config, { isDev, isClient }) {
if (isDev && isClient) {
config.module.rules.push({
enforce: 'pre',
test: /\.(js|vue)$/,
loader: 'eslint-loader',
exclude: /(node_modules)/
})
}
}
}
Similarly, the head
configuration also behaves differently based on whether it's placed within export default
or module.exports
. This inconsistency has led me to rely on trial and error for finding the correct placement.
Although I've come across references like module.exports vs. export default in Node.js and ES6, I am still puzzled as to why some configurations work better under module.exports
, while others favor export default
.
Any insights or explanations on this matter would be greatly appreciated.