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

    Access files in the root with simple method

    Framework
    4
    6
    3633
    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.
    • H
      Hariprasath last edited by

      i have mixin folder with some files inside the src folder of quasar
      i have files that present inside the folder with a long path
      when i want to access the mixin from the file i have to mention long parent path notation in the import statement
      if i have short method like ‘@’ symbol to access the ‘src’ folder directly from any file, i am very happy to use quasar
      i have this method in previous projects with vue and other vue templates

      1 Reply Last reply Reply Quote 1
      • s.molinari
        s.molinari last edited by

        You can also do relative imports by using ../ or ../../.

        This @ bit is a Webpack setting: https://webpack-gatsby.netlify.com/configuration/resolve/#resolve-alias

        Which you can change to your heart’s desire in quasar.conf.js. 😄

        https://quasar-framework.org/guide/app-quasar.conf.js.html#Extending-Webpack-Config-Object

        Scott

        DarkLite1 1 Reply Last reply Reply Quote 1
        • H
          Hariprasath last edited by Hariprasath

          OK Thank you very Much i got the result
          Just Include

              cfg.resolve.alias = {
                ...cfg.resolve.alias,
                '@': path.resolve(__dirname, './src')
              }
          

          at

              extendWebpack (cfg)
          

          function under build object and add

              var path = require('path')
          

          at top of the page

          kosirm 1 Reply Last reply Reply Quote 1
          • kosirm
            kosirm @Hariprasath last edited by kosirm

            @Hariprasath Thanks! It’s in documentation, but anyway 🙂

            1 Reply Last reply Reply Quote 0
            • DarkLite1
              DarkLite1 @s.molinari last edited by DarkLite1

              @s-molinari Just a small question on this. In the docs this is mentioned:
              f00a2b7d-d675-47b2-9856-054e391b72f5-image.png

              Does that mean when you can use the following:

              import authPopup from 'src/services/auth/authPopup'
              

              Or does it need to be prefixed like shown in many Webpack config?

              import authPopup from '@src/services/auth/authPopup'
              
              1 Reply Last reply Reply Quote 1
              • s.molinari
                s.molinari last edited by s.molinari

                Prefixing the aliases with ‘@’ is something Vue does in their project starter kit. Quasar doesn’t do that and yes, instead of doing ../ or ../../../ to travers up the folder hierarchy, you can just use src/your-path-here and you are good to go.

                And if you feel really rambunctious, you could also add the /services folder as an alias too, if you’ll be using it often, so all you’ll need to write is services/auth/authPopup. 🙂

                Scott

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