Skip to content
This repository has been archived by the owner on Dec 13, 2019. It is now read-only.

CoffeeScript support #66

Open
laurentpayot opened this issue Feb 26, 2018 · 11 comments
Open

CoffeeScript support #66

laurentpayot opened this issue Feb 26, 2018 · 11 comments

Comments

@laurentpayot
Copy link

laurentpayot commented Feb 26, 2018

For CoffeeScript I use the following /quasar.conf.js > build > extendWebpack(cfg).

      extendWebpack (cfg) {
        cfg.resolve.extensions.push('.coffee')
        // first rule is for Vue single file components
        cfg.module.rules[0].options.loaders.coffee = ['babel-loader', 'coffee-loader']
        cfg.module.rules.push({
          test: /\.coffee$/,
          loaders: ['babel-loader', 'coffee-loader'],
          include: [__dirname + '/src']
        })
      }

There is a trick with Vuex because the presence of store/index.js is hardcoded in https://github.com/quasarframework/quasar-cli/blob/dev/lib/quasar-config.js
so you can't use store/index.coffee. A quick workaround is to use the following store/index.js:

import store from './index.coffee'
export default store
@rstoenescu
Copy link
Member

@laurentpayot Can you generate a project with current 0.15 CLI (and choose "yes" to everything, including the store)? Then I'd need you to convert all .js files in the src to be .coffee files instead. Last step is to share that with me. I'll then add CoffeeScript support out of the box. Thank you!

@laurentpayot
Copy link
Author

@rstoenescu No problem. Will do that Monday morning.

@laurentpayot
Copy link
Author

@rstoenescu here is the repo you asked for: https://github.com/laurentpayot/quasar-CS-kit

@laurentpayot
Copy link
Author

Oops I forgot i18n and ie11 (default no), I'm going to add them asap…

@laurentpayot
Copy link
Author

Added i18n. Tested and ok, like the store by the way. ie11 support was just a boolean in quasar conf so I let it to false. Let me know if there are some issues.

@nothingismagick
Copy link
Contributor

@laurentpayot - is it possible for you to bring this up to speed for 0.16?

@laurentpayot
Copy link
Author

@nothingismagick hopefully will do that today or tomorrow.

@laurentpayot
Copy link
Author

laurentpayot commented May 25, 2018

Can't do that for quasar 0.16 my machine for now as I'm working with Vue CLI 3 and it seems incompatible with Quasar CLI:

laurent@asus:~/nodejs$ npm -v
6.1.0
laurent@asus:~/nodejs$ npm list -g --depth=0
/usr/local/lib
├── @vue/cli@3.0.0-beta.11
├── coffeescript@2.3.0
├── firebase-tools@3.18.5
├── n@2.1.11
├── npm@6.1.0
├── quasar-cli@0.16.1
└── snyk@1.80.1

laurent@asus:~/nodejs$ quasar init quasar016-CS-kit
 Running command: vue init 'quasarframework/quasar-starter-kit' quasar016-CS-kit

  Command vue init requires a global addon to be installed.
  Please run yarn global add @vue/cli-init and try again.

 app:init ⚠️ Something went wrong... Try running the "vue init" command above manually. +0ms
 app:init Reasons for failure: Package @vue/cli and @vue/cli-init are not installed globally, specified template is unavailable or it failed to download. +4ms

laurent@asus:~/nodejs$ 

Anyway the changes to make are described in the first post of this issue.

@nothingismagick
Copy link
Contributor

I am developing on quasar-cli and this is what I see when I run quasar info:

screen shot 2018-05-26 at 00 28 02

@laurentpayot
Copy link
Author

I meant I use Vue CLI 3. Modified my last comment.

@laurentpayot
Copy link
Author

laurentpayot commented May 29, 2018

As Quasar 0.16.2 is using webpack-chain, here are the webpack-chain config options for CoffeeScript I use with Vue CLI 3 . Should be the same for Quasar CLI (except maybe the cache-loader section).

chainWebpack: config => {
  config
    .entry('app')
      .clear()
      .add('./src/main.coffee')
      .end()
  config.resolve.extensions
    .prepend('.coffee')
  config.module
    .rule('coffeescript')
      .test(/\.coffee$/)
      .include
        .add(path.resolve(__dirname, './src'))
        .end()
      .exclude
        .add(path.resolve(__dirname, './node_modules'))
        .end()
      .use('coffee')
        .loader('coffee-loader')
        .end()
      .use('babel')
        .loader('babel-loader')
        .before('coffee') // see https://github.com/mozilla-neutrino/webpack-chain/issues/28
        .end()
      .use('cache')
        .loader('cache-loader')
        .before('babel') // see https://github.com/mozilla-neutrino/webpack-chain/issues/28
        .options({
          cacheDirectory: path.resolve(__dirname, './node_modules/.cache/cache-loader')
        })
        .end()
      .end()
},

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants