Why donate
API Explorer
Upgrade guide
NEW!
The quasar.config file
Convert to CLI with Webpack
Browser Compatibility
Supporting TypeScript
Directory Structure
Commands List
CSS Preprocessors
Routing
Lazy Loading - Code Splitting
Handling Assets
Boot Files
Prefetch Feature
API Proxying
Handling Webpack
Handling process.env
State Management with Pinia
State Management with Vuex
Linter
Testing & Auditing
Developing Mobile Apps
Ajax Requests
Opening Dev Server To Public
Quasar CLI with Webpack - @quasar/app-webpack
Configuring quasar.config file

Quasar makes use of some awesome development tools under its hood, like Webpack. One of the great things about Quasar is its handling of most of the complex configuration needed by the underlying tools for you. As a result, you don’t even need to know Webpack or any of the other development tools in order to use Quasar.

So what can you configure through the /quasar.config file?

TIP

You’ll notice that changing any of these settings does not require you to manually reload the dev server. Quasar detects and reloads the necessary processes. You won’t lose your development flow, because you can just sit back while Quasar CLI quickly reloads the changed code, even keeping the current state. This saves tons of your time!

WARNING

The /quasar.config file is run by the Quasar CLI build system, so this code runs under Node directly, not in the context of your app. This means you can require modules like ‘fs’, ‘path’, ‘webpack’, and so on. Make sure the ES features that you want to use in this file are supported by your Node version (which should be >= 14).

Structure

The basics

You’ll notice that the /quasar.config file exports a function that takes a ctx (context) parameter and returns an Object. This allows you to dynamically change your website/app config based on this context:

module.exports = function (ctx) { // can be async too
  console.log(ctx)

  // Example output on console:
  {
    dev: true,
    prod: false,
    mode: { spa: true },
    modeName: 'spa',
    target: {},
    targetName: undefined,
    arch: {},
    archName: undefined,
    debug: undefined
  }

  // context gets generated based on the parameters
  // with which you run "quasar dev" or "quasar build"
}

What this means is that, as an example, you can load a font when building for a certain mode (like PWA), and pick another one for the others:

module.exports = function (ctx) {
  extras: [
    ctx.mode.pwa // we're adding only if working on a PWA
      ? 'roboto-font'
      : null
  ]
}

Or you can use a global CSS file for SPA mode and another one for Cordova mode while avoiding loading any such file for the other modes.

module.exports = function (ctx) {
  css: [
    ctx.mode.spa ? 'app-spa.sass' : null, // looks for /src/css/app-spa.sass
    ctx.mode.cordova ? 'app-cordova.sass' : null  // looks for /src/css/app-cordova.sass
  ]
}

Or you can configure the dev server to run on port 8000 for SPA mode, on port 9000 for PWA mode or on port 9090 for the other modes:

module.exports = function (ctx) {
  devServer: {
    port: ctx.mode.spa
      ? 8000
      : (ctx.mode.pwa ? 9000 : 9090)
  }
}

You can also do async work before returning the quasar configuration:

module.exports = async function (ctx) {
  const data = await someAsyncFunction()
  return {
    // ... use "data"
  }
}

// or:
module.exports = function (ctx) {
  return new Promise(resolve => {
    // some async work then:
    // resolve() with the quasar config
    resolve({
      //
    })
  })
}

The possibilities are endless.

IDE autocompletion

You can wrap the returned function with configure() helper to get a better IDE autocomplete experience (through Typescript):

const { configure } = require('quasar/wrappers')

module.exports = configure(function (ctx) {
  /* configuration options */
})

Options to Configure

Let’s take each option one by one:

PropertyTypeDescription
cssArrayGlobal CSS/Sass/… files from /src/css/, except for theme files, which are included by default.
preFetchBooleanEnable PreFetch Feature.
extrasArrayWhat to import from @quasar/extras package. Example: [‘material-icons’, ‘roboto-font’, ‘ionicons-v4’]
vendorObjectAdd/remove files/3rd party libraries to/from vendor chunk: { add: […], remove: […] }.
supportTSBoolean/ObjectAdd support for TypeScript. More info
htmlVariablesObjectAdd variables that you can use in /index.html or /src/index.template.html.
frameworkObject/StringWhat Quasar components/directives/plugins to import, what Quasar language pack to use, what Quasar icon set to use for Quasar components.
animationsObject/StringWhat CSS animations to import. Example: [‘bounceInLeft’, ‘bounceOutRight’]
devServerObjectWebpack devServer options. Some properties are overwritten based on the Quasar mode you’re using in order to ensure a correct config. Note: if you’re proxying the development server (i.e. using a cloud IDE), set the public setting to your public application URL.
buildObjectBuild configuration options.
sourceFilesObjectChange the default name of parts of your app.
cordovaObjectCordova specific config.
capacitorObjectQuasar CLI Capacitor specific config.
pwaObjectPWA specific config.
ssrObjectSSR specific config.
electronObjectElectron specific config.

Property: css

Global CSS/Sass/… files from /src/css/, except for theme files, which are included by default.

/quasar.config file

return {
  css: [
    'app.sass', // referring to /src/css/app.sass
    '~some-library/style.css' // referring to node_modules/some-library/style.css
  ]
}

Property: vendor

By default, everything that comes from node_modules will be injected into the vendor chunk for performance & caching reasons. However, should you wish to add or remove something from this special chunk, you can do so:

/quasar.config file

return {
  vendor: {
    /* optional;
       disables vendor chunk: */ disable: true,

    add: [ 'src/plugins/my-special-plugin' ],
    remove: ['axios', 'vue$']
  }
}

Property: framework

Tells the CLI what Quasar components/directives/plugins to import, what Quasar I18n language pack to use, what icon set to use for Quasar components and more.

Filling “components” and “directives” is required only if “all” is set to false.

/quasar.config file

return {
  // a list with all options (all are optional)
  framework: {
    // is using "auto" import strategy, you can also configure:
    autoImportComponentCase: 'pascal', // or 'kebab' (default) or 'combined'

    // For special cases outside of where auto-import can have an impact
    // (example: vue components written in .js files instead of .vue),
    // you can manually specify Quasar components/directives to be available everywhere:
    //
    // components: [],
    // directives: [],

    // Quasar plugins
    plugins: ['Notify' /* ... */],

    // Quasar config
    // You'll see this mentioned for components/directives/plugins which use it
    config: { /* ... */ },

    iconSet: 'fontawesome-v6', // requires icon library to be specified in "extras" section too,
    lang: 'de', // Tell Quasar which language pack to use for its own components

    cssAddon: true // Adds the flex responsive++ CSS classes (noticeable bump in footprint)
  }
}

More on cssAddon here.

Property: devServer

Webpack devServer options. Take a look at the full list of options. Some are overwritten by Quasar CLI based on “quasar dev” parameters and Quasar mode in order to ensure that everything is setup correctly. Note: if you’re proxying the development server (i.e. using a cloud IDE or local tunnel), set the webSocketURL setting in the client section to your public application URL to allow features like Live Reload and Hot Module Replacement to work as described here.

Most used properties are:

PropertyTypeDescription
portNumberPort of dev server
hostStringLocal IP/Host to use for dev server
openBoolean/ObjectUnless it’s set to false, Quasar will open up a browser pointing to dev server address automatically. Applies to SPA, PWA and SSR modes. Uses open package params. For more details, please see below.
proxyObject/ArrayProxying some URLs can be useful when you have a separate API backend development server and you want to send API requests on the same domain.
devMiddlewareObjectConfiguration supplied to webpack-dev-middleware v4
serverObjectHere you can configure HTTPS instead of HTTP (see below)
onBeforeSetupMiddlewareFunctionConfigure the dev middlewares before webpack-dev-server applies its own config.
onAfterSetupMiddlewareFunctionConfigure the dev middlewares after webpack-dev-server applies its own config.

Using open prop to open with a specific browser and not with the default browser of your OS (check supported values). The options param described in previous link is what you should configure quasar.config file > devSever > open with. Some examples:

/quasar.config file

// (syntax below requires @quasar/app-webpack v3.3+)

// opens Google Chrome
devServer: {
  open: {
    app: { name: 'google chrome' }
  }
}

// opens Firefox
devServer: {
  open: {
    app: { name: 'firefox' }
  }
}

// opens Google Chrome and automatically deals with cross-platform issues:
const open = require('open')

devServer: {
  open: {
    app: { name: open.apps.chrome }
  }
}

When you set devServer > server > type: 'https' in your the /quasar.config file, Quasar will auto-generate a SSL certificate for you. However, if you want to create one yourself for your localhost, then check out this blog post by Filippo. Then your quasar.config file > devServer > server should look like this:

/quasar.config file

devServer: {
  server: {
    type: 'https', // NECESSARY (alternative is type 'http')

    options: {
      // Use ABSOLUTE paths or path.join(__dirname, 'root/relative/path')
      key: "/path/to/server.key",
      pfx: "/path/to/server.pfx",
      cert: "/path/to/server.crt",
      ca: "/path/to/ca.pem",
      passphrase: 'webpack-dev-server' // do you need it?
    }
  }
}

You can also configure automatically opening remote Vue Devtools:

/quasar.config file

devServer: {
  vueDevtools: true
}

Docker and WSL Issues with HMR

If you are using a Docker Container, you may find HMR stops working. HMR relies on the operating system to give notifications about changed files which may not work for your Docker Container.

A stop-gap solution can be achieved by using the polling mode to check for filesystem changes. This can be enabled with:

/quasar.config file

build: {
  // ...
  extendWebpack(cfg) {
    cfg.watchOptions = {
      aggregateTimeout: 200,
      poll: 1000,
    };
  },
// ...

Property: build

PropertyTypeDescription
transpileBooleanEnables or disables Babel transpiling.
transpileDependenciesArray of RegexDoes not applies if “transpile” is set to “false”. Add dependencies for transpiling with Babel (from node_modules, which are by default not transpiled). Example: [ /my-dependency/, ...]
showProgressBooleanShow a progress bar while compiling.
transformAssetUrlsObjectAdd support for also referencing assets for custom tags props. Example: { 'my-img-comp': 'src', 'my-avatar': [ 'src', 'placeholder-src' ]}
extendWebpack(cfg)FunctionExtend Webpack config generated by Quasar CLI. Equivalent to chainWebpack(), but you have direct access to the Webpack config object.
chainWebpack(chain)FunctionExtend Webpack config generated by Quasar CLI. Equivalent to extendWebpack(), but using webpack-chain instead.
beforeDev({ quasarConf })FunctionPrepare external services before $ quasar dev command runs, like starting some backend or any other service that the app relies on. Can use async/await or directly return a Promise.
afterDev({ quasarConf })FunctionRun hook after Quasar dev server is started ($ quasar dev). At this point, the dev server has been started and is available should you wish to do something with it. Can use async/await or directly return a Promise.
beforeBuild({ quasarConf })FunctionRun hook before Quasar builds app for production ($ quasar build). At this point, the distributables folder hasn’t been created yet. Can use async/await or directly return a Promise.
afterBuild({ quasarConf })FunctionRun hook after Quasar built app for production ($ quasar build). At this point, the distributables folder has been created and is available should you wish to do something with it. Can use async/await or directly return a Promise.
onPublish(opts)FunctionRun hook if publishing was requested ($ quasar build -P), after Quasar built app for production and the afterBuild hook (if specified) was executed. Can use async/await or directly return a Promise. opts is Object of form {arg, distDir}, where “arg” is the argument supplied (if any) to -P parameter.
publicPathStringPublic path of your app. By default, it uses the root. Use it when your public path is something else, like “<protocol>://<domain>/some/nested/folder” – in this case, it means the distributables are in “some/nested/folder” on your webserver.
appBaseStringForce app base tag with your custom value; configure only if you really know what you are doing, otherwise you can easily break your app. Highly recommended is to leave this computed by @quasar/app-webpack.
vueRouterBaseStringForce vue router base with your custom value; configure only if you really know what you are doing, otherwise you can easily break your app. Highly recommended is to leave this computed by @quasar/app-webpack.
vueRouterModeStringSets Vue Router mode: ‘hash’ or ‘history’. Pick wisely. History mode requires configuration on your deployment web server too.
htmlFilenameStringDefault is ‘index.html’.
ssrPwaHtmlFilenameStringUsed for SSR+PWA mode. Default is ‘offline.html’.
productNameStringDefault value is taken from package.json > productName field.
distDirStringFolder where Quasar CLI should generate the distributables. Relative path to project root directory. Default is ‘dist/{ctx.modeName}’. Applies to all Modes except for Cordova (which is forced to src-cordova/www).
ignorePublicFolderBooleanIgnores the /public folder. If you depend on a statics folder then you will need to configure it yourself (outside of Quasar or through the extendWebpack/chainWebpack), so make sure that you know what you are doing.
devtoolStringSource map strategy to use.
envObjectAdd properties to process.env that you can use in your website/app JS code.
gzipBoolean/ObjectGzip the distributables. Useful when the web server with which you are serving the content does not have gzip. If using as Object, it represents the compression-webpack-plugin config Object.
analyzeBoolean/ObjectShow analysis of build bundle with webpack-bundle-analyzer. If using as Object, it represents the webpack-bundle-analyzer config Object.
vueCompilerBooleanInclude vue runtime + compiler version, instead of default Vue runtime-only
uglifyOptionsObjectJS minification options. Full list
htmlMinifyOptionsObject(requires @quasar/app-webpack v3.10.2+) Minification options for html-minifier. Full list
vueLoaderOptionsObjectOptions (compilerOptions, compiler, transformAssetUrls, etc) for vue-loader.
scssLoaderOptionsObjectOptions to supply to sass-loader for .scss files. Example: scssLoaderOptions: { additionalData: ‘@import “src/css/abstracts/_mixins.scss”;’}
sassLoaderOptionsObjectOptions to supply to sass-loader for .sass files.
stylusLoaderOptionsObjectOptions to supply to stylus-loader.
lessLoaderOptionsObjectOptions to supply to less-loader.

The following properties of build are automatically configured by Quasar CLI depending on dev/build commands and Quasar mode. But if you like to override some (make sure you know what you are doing), you can do so:

PropertyTypeDescription
extractCSSBooleanExtract CSS from Vue files
sourceMapBooleanUse source maps
minifyBooleanMinify code (html, js, css)

If, for example, you run “quasar build --debug”, sourceMap and extractCSS will be set to “true” regardless of what you configure.

Property: htmlVariables

You can define and then reference variables in /index.html or /src/index.template.html, like this:

/quasar.config file

module.exports = function (ctx) {
  return {
    htmlVariables: {
      title: 'test name',
      some: {
        prop: 'my-prop'
      }
    }

Then (just an example showing you how to reference a variable defined above, in this case title):

/index.html or /src/index.template.html

<%= title %>
<%= some.prop %>

Property: sourceFiles

Use this property to change the default names of some files of your website/app if you have to. All paths must be relative to the root folder of your project.

/quasar.config file

// default values:
sourceFiles: {
  rootComponent: 'src/App.vue',
  router: 'src/router',
  store: 'src/store',
  indexHtmlTemplate: 'src/index.template.html',
  registerServiceWorker: 'src-pwa/register-service-worker.js',
  serviceWorker: 'src-pwa/custom-service-worker.js',
  electronMain: 'src-electron/electron-main.js',
  electronPreload: 'src-electron/electron-preload.js'
}

Example setting env for dev/build

Please refer to Adding to process.env section in our docs.

Handling Webpack configuration

In depth analysis on Handling Webpack documentation page.