Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dIEhv-0000EA-Rq for pgadmin-hackers@arkaria.postgresql.org; Tue, 06 Jun 2017 13:39:39 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dIEhv-00063s-9n for pgadmin-hackers@arkaria.postgresql.org; Tue, 06 Jun 2017 13:39:39 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dIEhu-00060Z-G0 for pgadmin-hackers@postgresql.org; Tue, 06 Jun 2017 13:39:38 +0000 Received: from mail-it0-x235.google.com ([2607:f8b0:4001:c0b::235]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1dIEhr-0006qi-Lg for pgadmin-hackers@postgresql.org; Tue, 06 Jun 2017 13:39:37 +0000 Received: by mail-it0-x235.google.com with SMTP id m47so92783027iti.1 for ; Tue, 06 Jun 2017 06:39:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pgadmin-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=36ye+AayYQ3+NQSD+AWrtDrRafMPPQgHBEvJILLMH/0=; b=sjggkbGho9hYmi7NAuXxvXwXlijmNbWJl1UqXmoBac81nr8sXjqhPDiT3kGcy8gBCO Cbyzc4sdTtvzO0EPdPcSGSFb8vs4kemEglqWVQTRPLX6bz5xAXBFSYMMw18C/7IwDuvt QzyGmzXbJud4nhUDPwvxWON5J4D0U/TdXlKGKJJH0pXd4W9v7DlYDFUC1Q7Jgac1FL21 6xWOot/DABG55xbEpR++Ybuq1EJieRNvFmA/EwP/hfF/n0xg+hBSpEQNKdudKnvXfo5I BBz8Uadyr6Z+PgNJbbxmff1mR9YlU1SdOqprhyKmd6ONy6oyIb6GzIJuaCEY/P/cEee9 nehg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=36ye+AayYQ3+NQSD+AWrtDrRafMPPQgHBEvJILLMH/0=; b=N/sKSyapAsHmVxTspSi1KHUVAQbsWpq6bhY8L33hH2ybNmNWG904/GzlKo5l0Msyy1 ZHyF8mOSwMLvbhUGduoRiDZQ4Cnwlxo1DeJpsTur0mIzhJEEIefW/Ef6rNKOZ3Ia7XLB Z3nxR2B97o9dyIFe6BpfaDrV5z5eJ8yQYVZLVxfSRWDZXnIPhg9gshlZYZF3TjlVa1/1 kciMGaGncCNWt3CM5QDS5jFLY7DK7swaLs2rhFp00Ags7pqZWkuLEpaUxT/2jgwG9btV 7DBKSmQ/DH5SrX7+Q9PBqGfzjr2g5ZXcBG9CJbKtfOqq6sYRz9B0+eY/bax1Hqm0IU9R UJhQ== X-Gm-Message-State: AODbwcB8sUcYd4qFUyTQYALEi1eI42EhjbJ/9i8uQlvmBDZl2CihjUZ2 Lty1pJXwzQjyI/ADcLPVY87PriwUATJf X-Received: by 10.36.74.3 with SMTP id k3mr18926009itb.28.1496756374011; Tue, 06 Jun 2017 06:39:34 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.174.147 with HTTP; Tue, 6 Jun 2017 06:39:33 -0700 (PDT) In-Reply-To: References: From: Dave Page Date: Tue, 6 Jun 2017 14:39:33 +0100 Message-ID: Subject: Re: [pgAdmin4][Patch]: Load module's JS files only when required To: Surinder Kumar Cc: Joao Pedro De Almeida Pereira , pgadmin-hackers Content-Type: text/plain; charset="UTF-8" X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgadmin-hackers Precedence: bulk Sender: pgadmin-hackers-owner@postgresql.org Hi On Mon, Jun 5, 2017 at 10:22 AM, Surinder Kumar wrote: > Hi Dave, > > Please find attached patch for minifying CSS files and optimize images using > Webpack. > > Steps to run: > > 1) After applying patch, go to web directory and run npm install on terminal > to install packages which are used to parse/minify CSS files. > > 2) Run npm run build which creates dist folder inside web/pgadmin/static/ > directory to store processed images, fonts and css files. > > 3. Set DEBUG = False in config_local.py and then run python pgAdmin.py to > start server. > I kept generated main.css and overrides.css conditional in base.html to load > them only when debug mode is False > > > After running "npm run build", following files/directories are generated: > > 1) main.css - about 20 vendor CSS files are packed into this file and more > importantly the paths to images are preserved. > > 2) overrides.css - it contains bootstrap.overrides.css and pgadmin.css, they > has to be packed separately and loaded after all CSS files are loaded > because the purpose of these files is to override the vendor or modules css. > > 3) img - it contains the images used in CSS files. The name of image files > can also be hashed names for caching purpose which we can use. > > 4) fonts - it contains the fonts used in fontawesome.css and other css > files. > > This is a simple patch to demonstrate how CSS files will be minified with > Webpack. I think this is a good, simple method. It handles debug v.s release, and of course, any plugin modules can include their own images/CSS without even having to worry about webpacking if installed later. > For now it minifies only vendor CSS files, I will add modules static files > in the list later on. I think we need to do that to get a better idea of the benefits. We also need to get some of the JS code in there as well (Ashesh should be able to help with that - he told me he's de-templatised a lot of that now). > Any thoughts on minifying template CSS files which are built dynamically and > loaded with dependency on other modules? Let's look at why they are templates. Is that required, or could they be made static? > Also, I looked into Flask-webpack which generates bundled assets using > Webpack(webpack.config.js) and provide additionally global template tags to > use in Jinja templates. > > But it might not work with latest version of Webpack as this repo is not > updated since last 2 years. I need to check with latest version and I will > update on this. Given how straightforward this seems to be, I'm not sure it's needed. Joao, any comments? Nice work - thanks! -- Dave Page Blog: http://pgsnake.blogspot.com Twitter: @pgsnake EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgadmin-hackers