webpack-contrib / coffee-loader

CoffeeScript Loader
MIT License
143 stars 54 forks source link

.vue file support #59

Closed acidjazz closed 4 years ago

acidjazz commented 6 years ago

Any chance we can get support for .vue files?

<template lang="pug">
</template>

 <script lang="coffee">
module.exports= 
  data: ->
    number: 20 
</script>

<style lang="stylus">
@import '../../assets/stylus/guide/includes/*'
</style>

my error:

Module build failed: Error: /Users/k/sake-new/node_modules/vue-loader/lib/selector.js?type=script&index=0!/Users/k/sake-new/pages/work/_project.vue:6:9: error: unexpected )
  data () {
        ^
    L5:   data () {
                 ^

    at Object.module.exports (/Users/k/sake-new/node_modules/coffee-loader/index.js:38:9)

 @ ./pages/work/_project.vue 8:0-109 9:0-122
 @ ./.nuxt/router.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi webpack-hot-middleware/client?name=client&reload=true&timeout=30000&path=/__webpack_hmr ./.nuxt/client.js
shreeve commented 6 years ago

Any update on this? Thx

tlongzou commented 6 years ago

That works for me, show me you webpack config.

acidjazz commented 6 years ago

@tlongzou I use the nuxt.js framework, so i don't really have my own custom config. try a quick setup of it to see

vue init nuxt-community/starter-template <project-name>

https://nuxtjs.org/guide/installation

tlongzou commented 6 years ago

@acidjazz @shreeve

nuxt template project is enable eslint by default in nuxt.config.js:23 you can remove or commented out that.

kyrsquir commented 6 years ago

Simply disabling eslint as many suggested didn't work for me to make nuxt recognise coffeescript in .vue files. What helped is also adding the following to nuxt.config.js:

build: {
  extend(config, ctx) {
    config.module.rules.push({
      test: /\.(coffee)$/,
      use: [{ loader: 'coffee-loader' }]
    })
  }
}

It seems coffee-loader isn't being recognised automatically by nuxt.

manniL commented 6 years ago

@kyrsquir Exactly, you have to extend your webpack config by using build.extend.

This is also shown in our official coffescript example.

alexander-akait commented 4 years ago

Closing due to inactivity. Please test with latest version and feel free to reopen if still regressions. Thanks!

I think it is out of scope coffee-loader, you need open issue in vue-cli