No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Why is there no webpack alias to src by default?

    Framework
    cli test
    4
    6
    1480
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Jezzta667
      Jezzta667 last edited by

      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

      1 Reply Last reply Reply Quote 0
      • rstoenescu
        rstoenescu Admin last edited by

        You don’t need that…

        https://v1.quasar-framework.org/quasar-cli/cli-documentation/handling-webpack#Webpack-Aliases

        Jezzta667 1 Reply Last reply Reply Quote 0
        • Jezzta667
          Jezzta667 @rstoenescu last edited by

          @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?

          1 Reply Last reply Reply Quote 0
          • N
            newbro last edited by

            I too don’t understand why ‘@’ isn’t used here to be more aligned with others behavior, I’d understand sometime a bit difference here or there would make your work stand out but I don’t think this is one of them.

            1 Reply Last reply Reply Quote 0
            • dmitry.polushkin
              dmitry.polushkin last edited by

              Yes, I remember I was first time confused about src alias, but now I’m ok with it, as mainly working with quasar-only.

              Main issue I have that IDE (intellij) always trying to use relative paths for the modules. Probably it’s possible to configure it somewhere, but by this moment I’m fixing that by hands.

              1 Reply Last reply Reply Quote 0
              • dmitry.polushkin
                dmitry.polushkin last edited by

                It’s possible to use webpack with IDEA IDE: https://www.jetbrains.com/help/idea/using-webpack.html
                Just set separate webpack.js file and include it into the quasar.conf.js

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post