Cannot set property 'coffee' of undefined
chiboreache opened this issue · 4 comments
chiboreache commented
Hi!
I added module to my freshly created project via npx create-nuxt-app
/*
** Nuxt.js modules
*/
modules: [ 'nuxt-coffeescript-module'
],
but it doesn't work for some reason ~_~
ERROR Cannot set property 'coffee' of undefined 05:08:40
at WebpackBundler.extendBuild.config (node_modules/nuxt-coffeescript-module/index.js:26:33)
at WebpackBundler.<anonymous> (node_modules/@nuxt/common/dist/common.js:1344:25)
at WebpackClientConfig.extendConfig (node_modules/@nuxt/webpack/dist/webpack.js:4570:56)
at WebpackClientConfig.extendConfig (node_modules/@nuxt/webpack/dist/webpack.js:4719:26)
at WebpackClientConfig.config (node_modules/@nuxt/webpack/dist/webpack.js:4608:33)
at WebpackClientConfig.config (node_modules/@nuxt/webpack/dist/webpack.js:4761:26)
at WebpackBundler.build (node_modules/@nuxt/webpack/dist/webpack.js:4993:56)
at Builder.build (node_modules/@nuxt/builder/dist/builder.js:5735:30)
and my package.json
"dependencies": {
"cross-env": "^5.2.0",
"nuxt": "^2.3.4",
"nuxt-coffeescript-module": "^1.2.0"
},
"devDependencies": {
"nodemon": "^1.18.9"
}
}
chiboreache commented
yeah, that would be handy to have nuxt.config in coffee format, since solution provided in oficial repo doesn't support it
or maybe it's just me heh
require('./modules/coffeescript.js')
import all from './nuxt.config.coffee'
export default function () {
// Add .coffee extension for store, middleware and more
this.nuxt.options.extensions.push('coffee')
// Extend build
const coffeeLoader = {
test: /\.coffee$/,
loader: 'coffee-loader'
}
this.extendBuild((config) => {
// Add CoffeeScruot loader
config.module.rules.push(coffeeLoader)
// Add .coffee extension in webpack resolve
if (config.resolve.extensions.indexOf('.coffee') === -1) {
config.resolve.extensions.push('.coffee')
}
})
}
gaven commented
@weotch @chiboreache I believe that with Nuxt versions >= 2.0 you can just use coffeescript
and coffee-loader
, see: https://nuxtjs.org/faq/pre-processors/. To use coffeescript
in your nuxt config
you need to do something like this:
require('coffeescript/register')
module.exports = require('./nuxt.config.coffee')
chiboreache commented
@gaven -- WORKS LIKE A CHARM
Thank you man!
btw faq is outdated (atleast pre-processors part), so it is a bad reference