MyGit

v0.17.0

quasarframework/quasar-cli

版本发布时间: 2018-07-25 22:16:24

quasarframework/quasar-cli最新发布版本:0.17.26(2019-07-11 18:06:00)

This is a big release, introducing SSR. Enjoy!

New

SSR mode (+ optional PWA takeover)

SSR mode (ONLY) small required changes

These changes will be required by the Quasar CLI only when you build with SSR mode. After doing these changes you'll still be able to build the other modes (SPA/PWA/Cordova/Electron) too.

src/router/index.js

You need to have a default export set to "function ({ store })" which returns a new instance of Router instead of default exporting the Router instance itself.

// OLD WAY
  import Vue from 'vue'
  import VueRouter from 'vue-router'
  import routes from './routes'
  Vue.use(VueRouter)

  // in the new way, we'll wrap the instantiation into:
  // export default function ({ store }) --> store is optional
  const Router = new VueRouter({
    scrollBehavior: () => ({ y: 0 }),
    routes,
    // Leave these as they are and change from quasar.conf.js instead!
    mode: process.env.VUE_ROUTER_MODE,
    base: process.env.VUE_ROUTER_BASE,
  })

  // in the new way, this will be no more
  export default Router

// NEW WAY
  import Vue from 'vue'
  import VueRouter from 'vue-router'
  import routes from './routes'
  Vue.use(VueRouter)

  // DO NOT import the store here as you will receive it as
  // parameter in the default exported function:

  export default function (/* { store } */) {
    // IMPORTANT! Instantiate Router inside this function

    const Router = new VueRouter({
      scrollBehavior: () => ({ y: 0 }),
      routes,
      // Leave these as they are and change from quasar.conf.js instead!
      mode: process.env.VUE_ROUTER_MODE,
      base: process.env.VUE_ROUTER_BASE,
    })

    return Router
  }

src/store/index.js

You need to have a default export set to "function ()" which returns a new instance of Vuex Store instead of default exporting the Store instance itself.

Some of you might need the Router instance on the Store. It is accessible through this.$router inside your actions, mutations, etc.

// OLD WAY
  import Vue from 'vue'
  import Vuex from 'vuex'
  import example from './module-example'
  Vue.use(Vuex)

  // in the new way, we'll wrap the instantiation into:
  // export default function ()
  const store = new Vuex.Store({
    modules: {
      example
    }
  })

  // in the new way, this will be no more
  export default store

// NEW WAY
  import Vue from 'vue'
  import Vuex from 'vuex'
  import example from './module-example'
  Vue.use(Vuex)

  export default function () {
    // IMPORTANT! Instantiate Store inside this function

    const Store = new Vuex.Store({
      modules: {
        example
      }
    })

    return Store
  }

Also, if you want to be able to access the Router instance from vuex actions, mutations, etc, you need to make some simple changes (in all of them):

// OLD WAY:
export const someAction = (context) => { ... }

// NEW WAY:
export function someAction (context) {
  // now we have access to:
  this.$router
}

App Plugins

Here's a full list of the parameters for app plugins:

// ...
export default ({
  app, // the Vue instantiation Object for the app
  router, // the instantiated Vue Router of your app
  store, // the instantiated Vuex Store (if using one)
  Vue, // so you don't need to "import Vue from 'vue'"
  ssrContext // the SSR context (when running server-side only)
}) => {
  // ...
}

Quasar "serve" command

"$ quasar serve <...options>" creates a customizable and optimized ad-hoc static webserver that can be used for quick testing (or on production too!).

Type "$ quasar serve -h" for all the options.

# example
$ quasar serve dist/spa-mat

Tree-shaking on Quasar

This has been improved near to perfection, avoiding some webpack pitfalls. The final build of your app will include ONLY & EXACTLY what you cherry-picked from Quasar.

New quasar.conf option

Other new features

Improvements

Fixes

相关地址:原始地址 下载(tar) 下载(zip)

查看:2018-07-25发行的版本