Re: [pgadmin-hackers] [pgAdmin4][Patch]: Load module's JS files onlywhen required

Поиск
Список
Период
Сортировка
От Surinder Kumar
Тема Re: [pgadmin-hackers] [pgAdmin4][Patch]: Load module's JS files onlywhen required
Дата
Msg-id CAM5-9D9UGqvoYkTmfjC+zEfD1WkdqGp8mi4Lk9+8X2EBD8x8LA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [pgadmin-hackers] [pgAdmin4][Patch]: Load module's JS files onlywhen required  (Dave Page <dpage@pgadmin.org>)
Ответы Re: [pgadmin-hackers] [pgAdmin4][Patch]: Load module's JS files onlywhen required  (Dave Page <dpage@pgadmin.org>)
Список pgadmin-hackers
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.

For now it minifies only vendor CSS files, I will add modules static files in the list later on.

Any thoughts on minifying template CSS files which are built dynamically and loaded with dependency on other modules?

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.


Thanks
Surinder


On Mon, May 29, 2017 at 5:45 AM, Dave Page <dpage@pgadmin.org> wrote:
On Fri, May 26, 2017 at 12:01 AM, Surinder Kumar
<surinder.kumar@enterprisedb.com> wrote:
> On Fri, May 26, 2017 at 3:02 AM, Dave Page <dpage@pgadmin.org> wrote:
>>
>> On Tue, May 23, 2017 at 4:21 PM, Dave Page <dpage@pgadmin.org> wrote:
>> >
>> > I'm actually thinking that maybe it would be easier to start with the
>> > CSS files....
>>
>> Which i did yesterday. However, it soon became obvious that that isn't
>> so easy either, as the CSS files contain url references which need to
>> be adjusted, which isn't trivial.
>>
>> However, I did find a flask-webpack module, which looks interesting:
>>
>> https://github.com/nickjj/flask-webpack
>> https://nickjanetakis.com/blog/manage-your-assets-with-flask-webpack
>>
>> Surinder; when you have some free time, could you look into a simple
>> PoC with the CSS files using that please?
>
> Ok. I will look

BTW; if it looks like it will take a while to implement (as I
suspect), we should consider polishing off your initial patch as an
interim step. Any thoughts on how long RM2424 would take to resolve?


--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Вложения

В списке pgadmin-hackers по дате отправления:

Предыдущее
От: Dave Page
Дата:
Сообщение: Re: [pgadmin-hackers] [pgAdmin4] To Extract or Not To Extract - Thatis the Question
Следующее
От: Murtuza Zabuawala
Дата:
Сообщение: Re: [pgadmin-hackers] [pgAdmin4] Feature tests fails on smaller screen resolution