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

    .js files inside public folder are modified on build process

    Help
    3
    6
    427
    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.
    • T
      Taras last edited by Taras

      Quasar v1.14.1
      Quasar app 2.1.1

      I have .js file inside public directory. After build process (quasar build) I get modified version of file.

      It is a problem for me, because this file shoud remain as JSON string, but compiler collapses spaces and makes other unexpected modifications to file. It becomes JS Object, but not JSON string after that.

      So, why is that? As I understand no modifications to files should be made inside public directory. I need this file to be ported AS IS.

      How can I fix it?

      export default {
        "readme": "sadasf",
      
        "version": {
          "major": 0,
          "minor": 45,
          "patch": 20
        }
      };
      

      it becomes

      export default{readme:"sadasf",version:{major:0,minor:45,patch:20}};
      

      without quotes (") and so on…

      1 Reply Last reply Reply Quote 0
      • Hawkeye64
        Hawkeye64 last edited by

        @Taras Then try making it a true JSON object. Currently, you have it hosted as a JS file with export default. That’s a js object.
        You can import JSON without making it a js object.

        1 Reply Last reply Reply Quote 1
        • T
          Taras last edited by

          @Hawkeye64 , thank you for reply. But I use this file in two different ways. I import it in my project usign import function and I download it from server using axios during runtime and parse it as JSON string… Doing so I can understand if I use last version during runtime or from browser cache and i should force to reload page…
          How should I force webpack not to modify .js files in public folder, but at the same time import it during compilation

          1 Reply Last reply Reply Quote 0
          • T
            Taras last edited by

            It’s declared that no changes to files will be done inside public. Why do I get result that described?

            beets 1 Reply Last reply Reply Quote 0
            • beets
              beets @Taras last edited by

              @Taras I think what hawkeye is saying, is that you should make the file an actual JSON file, as in named public/version.json with contents:

              {
                "readme": "sadasf",
              
                "version": {
                  "major": 0,
                  "minor": 45,
                  "patch": 20
                }
              }
              

              You should still be able to require this file. Webpack is likely changing it because it’s a JS file, and you require it in your project.

              1 Reply Last reply Reply Quote 1
              • T
                Taras last edited by

                @beets Thank you for clarification. I required plain json file and it worked for me. My issue solved.
                @Hawkeye64 Thank you for your reply again. Now I understand what you really meant

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