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

    Tip: PurgeCSS works perfectly with Quasar

    Useful Tips (NEW)
    2
    4
    474
    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.
    • S
      suleiman_as last edited by suleiman_as

      Hello Everyone,
      I just want to share my results after so many failed attempts to integrate purgecss with webpack. I only managed to make it work after the build, so this is my idea:

      • install purgecss globally
      npm install -g purgecss
      
      • add purgecss --config ./purgecss.config.js in the scripts after the build
      "scripts": {
          "build": "quasar build && purgecss --config ./purgecss.config.js"
      }
      
      • make a purgecss.config.js file and just whitelist what I need
      module.exports = {
        content: ["./dist/spa/js/*.js"],
        css: ["./dist/spa/css/*.css"],
        output: ["./dist/spa/css/"],
        fontFace: true,
        keyframes: true,
        variables: true,
        rejected: true,
        safelist: {
          standard: [/fixed-.*/, /absolute-.*/, /q-btn.*/, /justify-.*/]
        }
      };
      

      Thats it…

      dobbel 1 Reply Last reply Reply Quote 2
      • dobbel
        dobbel @suleiman_as last edited by dobbel

        @suleiman_as

        So no more missing quasar component classes anymore when using purgecss ? What version of Quasar are you using Qv1 or the beta Qv2?

        Just tested your setup in Qv1, it unfortunately does not work correctly, it removes to much and some components will not render correctly.

        S 1 Reply Last reply Reply Quote 0
        • S
          suleiman_as @dobbel last edited by

          @dobbel I’m using Qv1, sure it differs from project to another but if I find something missing I would just add it to the safelist.

          dobbel 1 Reply Last reply Reply Quote 0
          • dobbel
            dobbel @suleiman_as last edited by dobbel

            @suleiman_as

            I would just add it to the safelist.

            Yes that works. Not ideal but finally some reduced css size for Quasar apps. Good work!

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