Why is there no webpack alias to src by default?



  • Vue CLI provides a webpack alias to the src folder via ‘@’

    Why is this not the same with Quasar? It means that existing Vue users must spend time searching for how to make this work.

    To add an alias, go to quasar.conf.js, find the following code and add the lines between the comments:

    ...
          extendWebpack (cfg) {
            cfg.module.rules.push({
              enforce: 'pre',
              test: /\.(js|vue)$/,
              loader: 'eslint-loader',
              exclude: /node_modules|quasar/,
              options: {
                cache: true
              }
            })
            // Add the following code
            cfg.resolve.alias = {
              ...cfg.resolve.alias,
              '@': path.resolve(__dirname, 'src')
            }
            ////
          }
    ...
    

    To provide the same alias to your Jest testing environment, go to jest.config.js and add:

    '^@/(.*)$': '<rootDir>/src/$1', to the moduleNameMapper object


  • Admin



  • @rstoenescu my main concern is that not mapping ‘@’ is different to what Vue does by default. Some people will be copying existing Vue components across to their Quasar project. Why not make it the same?

    Additionally, I apologise for missing this section of the documentation, but it’s easy to do without a search function. Are the docs going to be searchable soon?