Quasar Framework Vue CLI Plugin
The `vue-cli-plugin-quasar` package facilitates the integration of Quasar Framework v2 with Vue CLI v5 projects. It provides the necessary webpack configurations, build tools, and scaffolding to jumpstart the development of Quasar-powered Vue 3 applications. While this plugin enables developers to utilize Quasar within an existing Vue CLI ecosystem, it's crucial to acknowledge that Vue CLI itself is currently in maintenance mode. For a comprehensive and premium Quasar development experience, which includes robust support for building Mobile and Electron applications, along with seamless upgrades, the Quasar Framework team strongly recommends using the dedicated Quasar CLI. The current stable version of this plugin is 5.1.2. Its primary role is to configure a Vue CLI project to correctly bundle and optimize Quasar components, rather than acting as a runtime library itself.
Common errors
-
Module not found: Error: Can't resolve 'loader-utils' in '.../node_modules/vue-cli-plugin-quasar'
cause When using Yarn 2 Plug'n'Play (PNP) mode, an implicit dependency on `loader-utils` by `vue-cli-plugin-quasar` was not explicitly listed in its `package.json`.fixUpgrade `vue-cli-plugin-quasar` to version 5.0.2 or higher, which includes a fix for this Yarn 2 PNP compatibility issue by adding `loader-utils` as a dependency. -
Error: Trailing comma is not permitted in JSON
cause Older versions of the plugin contained a bug that caused incorrect transformation of Quasar imports, sometimes introducing trailing commas in generated code or configuration, leading to parse errors.fixUpgrade `vue-cli-plugin-quasar` to version 4.0.3 or higher to resolve issues related to incorrectly transformed imports that could cause syntax errors. -
DEP_WEBPACK_RULE_LOADER_OPTIONS_STRING: DeprecationWarning: Using a string as a loader's options is deprecated. Please use an object instead.
cause Older plugin versions used a deprecated method for passing options to Webpack loaders, triggering warnings in Webpack 5 due to changes in its API.fixUpgrade `vue-cli-plugin-quasar` to version 4.0.2 or higher, which includes a fix addressing Webpack 5 loader options deprecations, resolving these warning messages.
Warnings
- breaking Vue CLI v5 is a strict requirement for `vue-cli-plugin-quasar` v5.x. Earlier versions of Vue CLI (e.g., v4) are incompatible and not supported, leading to build errors or unexpected behavior.
- breaking When upgrading a project from Vue CLI v4 to v5 and using this plugin, specific dependency versions for `sass`, `sass-loader`, and `postcss-rtl` were crucial. Failure to pin these to the correct versions (`sass: 1.32.12`, `sass-loader: ^12.0.0`, `postcss-rtl: ^3.5.3`) could result in build failures.
- breaking Since `vue-cli-plugin-quasar` v5.1.2, `postcss-rtlcss` has replaced `postcss-rtl`. If you had `postcss-rtl` installed, you may need to manually uninstall it and install `postcss-rtlcss` to ensure correct RTL processing and avoid potential conflicts.
- gotcha The `vue-cli-plugin-quasar` version 5.1.0 and above requires Quasar Framework v2.16+ as a minimum dependency. Using an older Quasar version will lead to compatibility issues.
- gotcha Vue CLI, which is fundamental to this plugin, is currently in maintenance mode. For the most robust and feature-rich Quasar development experience, particularly for mobile/Electron apps and seamless version upgrades, the Quasar team recommends using the official Quasar CLI directly instead of `vue-cli-plugin-quasar`.
Install
-
npm install vue-cli-plugin-quasar -
yarn add vue-cli-plugin-quasar -
pnpm add vue-cli-plugin-quasar
Imports
- Plugin Installation/Activation
import { QuasarPlugin } from 'vue-cli-plugin-quasar'$ vue invoke quasar
- Quasar Configuration Options
import QuasarConfig from 'vue-cli-plugin-quasar/config'
// vue.config.js module.exports = { pluginOptions: { quasar: { importStrategy: 'auto', rtlSupport: true } } } - Auto-Imported Quasar Components
import { Quasar } from 'vue-cli-plugin-quasar'// MyComponent.vue <template> <q-btn label="Hello Quasar" @click="sayHi" /> </template> <script setup> import { QBtn } from 'quasar' // For type hinting and explicit imports, though often implicit const sayHi = () => alert('Hi!'); </script>
Quickstart
# Ensure Vue CLI v5 is installed vue --version # If Vue CLI v5 is not installed, install or upgrade globally: # npm install -g @vue/cli # # OR # yarn global add @vue/cli # Create a new Vue CLI project (choose Vue 3 and default options for simplicity) vue create my-quasar-app # Navigate into your newly created project folder cd my-quasar-app # (Recommended) Commit existing changes before adding the plugin, to easily revert if needed # git init # git add . # git commit -m "Initial Vue CLI project" # Add the Quasar CLI plugin as a development dependency yarn add --dev vue-cli-plugin-quasar # # OR # npm install --save-dev vue-cli-plugin-quasar # Invoke the plugin to integrate Quasar Framework into your project vue invoke quasar # Follow the prompts; it's generally recommended to allow the plugin to replace example files. # Now you can run your Quasar-enabled Vue application yarn serve # # OR # npm run serve