App Pre-Processors & Webpack     

The build system uses Webpack to create your website/app. Don’t worry if you aren’t acquainted with Webpack. Out of the box, you won’t need to configure it because it already has everything set up.

However, for cases where you need to tweak the default Webpack config you can do so by editing /quasar.conf.js and configuring build > extendWebpack (cfg) method.

Example of adding ESLint loader to it (assuming you’ve installed it):

build: {
extendWebpack (cfg) {
enforce: 'pre',
test: /\.(js|vue)$/,
loader: 'eslint-loader',
exclude: /(node_modules|quasar)/

Notice that you don’t need to return anything. The parameter of extendWebpack(cfg) is the Webpack configuration Object generated by Quasar for you. You can add/remove/replace anything from it, assuming you really know what you are doing.

Let’s discuss about Webpack loaders now. It’s probably where you’ll make the most additions.

Webpack Loaders

The build system uses Webpack, so it relies on using webpack loaders to handle different types of files (js, css, styl, scss, json, and so on). By default, the most used loaders are provided by default.

Installing loaders:

Let’s take an example. You want to be able to import .json files. Out of the box, Quasar supplies json support so you don’t actually need to follow these steps, but for the sake of demonstrating how to add a loader, we’ll pretend Quasar doesn’t offer it.

So, you need a loader for it. You search Google to see what webpack loader you need. In this case, it’s “json-loader”. We first npm install it:

$ npm install json-loader --save-dev

After installing your new loader, we want to tell Webpack to use it. So we edit /quasar.conf.js and change build.extendWebpack() to add entries to module/rules for this new loader:

build: {
extendWebpack (cfg) {
test: /\.json$/,
loader: 'json-loader'

And you’re done.

SASS/SCSS support

So you want to be able to write SASS/SCSS CSS code. You need a loader for it. We first npm install it. Note that for this particular case you also need to install node-sass because sass-loader depends on it as a peer dependency.

$ npm install sass-loader node-sass --save-dev

And you’re done. For SCSS/SASS it’s all it takes. You don’t need to further configure /quasar.conf.js.

Once installed, you can use this pre-processor inside your *.vue components using the lang attribute on <style> tags:

<style lang="scss">
/* We can write SASS now! */

A note on SASS syntax:


Styles in *.vue files (and all other style files) are piped through PostCSS by default, so you don’t need to use a specific loader for it.

By default, PostCSS is configured to use Autoprefixer. Take a look at `/.postcssrc.js where you can tweak it if you need to.


If you are using Coffeescript then you need to EITHER disable ESLint OR tell ESLint which Vue components are using Coffeescript.

Note that vue-loader uses lang="coffee" to identify components which are using Coffeescript, but lang="coffee" is not recognizable for ESLint. Fortunately, ESLint (following traditional HTML) uses type="xxx" to identify the type of scripts. As long as a <script> tag has any type other than javascript, ESLint would mark the script as non-javascript, and skips linting it. Coffeescript’s convention is to use type="text/coffeescript" to identify itself. Therefore, in your Vue components which are using Coffeescript, using both lang and type to avoid ESLint warnings:

<script lang="coffee" type="text/coffeescript">