quasarframework / quasar-cli

[DEPRECATED, <= 0.17) Quasar Framework - CLI
https://quasar.dev
MIT License
203 stars 50 forks source link

CoffeeScript support #66

Open laurentpayot opened 6 years ago

laurentpayot commented 6 years ago

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 commented 6 years ago

@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 commented 6 years ago

@rstoenescu No problem. Will do that Monday morning.

laurentpayot commented 6 years ago

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

laurentpayot commented 6 years ago

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

laurentpayot commented 6 years ago

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 commented 6 years ago

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

laurentpayot commented 6 years ago

@nothingismagick hopefully will do that today or tomorrow.

laurentpayot commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

laurentpayot commented 6 years ago

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