quasar-cli icon indicating copy to clipboard operation
quasar-cli copied to clipboard

CoffeeScript support

Open laurentpayot opened this issue 7 years ago • 11 comments

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

laurentpayot avatar Feb 26 '18 13:02 laurentpayot

@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!

rstoenescu avatar Mar 02 '18 17:03 rstoenescu

@rstoenescu No problem. Will do that Monday morning.

laurentpayot avatar Mar 02 '18 18:03 laurentpayot

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

laurentpayot avatar Mar 05 '18 16:03 laurentpayot

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

laurentpayot avatar Mar 05 '18 18:03 laurentpayot

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.

laurentpayot avatar Mar 05 '18 19:03 laurentpayot

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

nothingismagick avatar May 20 '18 23:05 nothingismagick

@nothingismagick hopefully will do that today or tomorrow.

laurentpayot avatar May 23 '18 09:05 laurentpayot

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/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

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.

laurentpayot avatar May 25 '18 18:05 laurentpayot

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

nothingismagick avatar May 25 '18 22:05 nothingismagick

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

laurentpayot avatar May 29 '18 19:05 laurentpayot

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()
},

laurentpayot avatar May 29 '18 19:05 laurentpayot