yiister / yii2-gentelella

Free admin template for backend
MIT License
275 stars 113 forks source link

minimal installation #16

Open mtangoo opened 7 years ago

mtangoo commented 7 years ago

I have found there are a lot of things that are just waste and somone can install what he want (all plotting stuffs et al,) plus duplication of things like Jquery which Yii2 already bundles. I suggest they get removed and instruction on how to add them for anyone in need will be handy.

I wanted to make pull request but unfortunately have not found time to do so

fps01 commented 7 years ago

Hello @mtangoo ! yii2-gentelella requires only nesessary packages for layout displaying. For example, original Gentelella theme has many charts. We don't include it. The extension uses a Yii jquery bundle and doesn't download any another. Please describe an issue more informative.

mtangoo commented 7 years ago

@fps01 That is what I expected. However looking at the vendor directory after installation there are all those files am talking about. The issue is easy to reproduce:

  1. install extension
  2. check files in extension folder
nelsonpoon commented 7 years ago

Oh , yeah ... i have check it the location is @webroot/vendor/bower/gentelella/vendors ... there is about 93MB

fps01 commented 7 years ago

So it's a structure of a theme repository. I know that a bigger part of it does not used but I do not see a pretty solution. @nelsonpoon , @mtangoo Can you suggest solution?

P.S. A way with a fork of the theme repository is bad idea.

mtangoo commented 7 years ago

The first thing that came in my mind is don't install any of bower packages. Yii2 already provides JQuery, bootstrap and Jquery UI. You can provide a bower package which user can use to install packages (after editing out what he need). Only core bundles that are essential should be included by default.

I would split asset class into two, Basic and Advanced. The basic one will have core stuffs and advanced will extend core with extras (which user will have to download somehow).

TL;DR - Install core assets and let user extend asset bundle and add whatever extra asset he wants

fps01 commented 7 years ago

@mtangoo The repository that's used as theme already contains installed bower packages. I can't download all directories excluding a vendor. Or didn't I understand you?

nelsonpoon commented 7 years ago

@fps01 @mtangoo I am a newber of yii2 and yii2 extension , I have no idea to how to remove the JQuery from Yii2-gentelella ,but i think the following packages might be removed that was exists 1.1M jquery (@webroot/vendor/bower/jquery/) 1.1M jquery.inputmask (@webroot/vendor/bower/jquery.inputmask/) 1.3M font-awesome (@webroot/vendor/fortawesome/font-awesome) 2.5M bootstrap (@webroot/vendor/yiisoft/yii2-bootstrap)

mtangoo commented 7 years ago

@fps01 The file installs all those packages see this and that can be avoided by (as far as I see) by removing the bower dependency on composer.json. The Widget seems to depend only on three js files and two css files (reading from asset classes). That can be easily included with widget and updated only when tagging new releases or when some big bug is fixed on original repo. That way we can avoid the problem.

@nelsonpoon do not remove all those (except may be font-awesome which is dependency of this widget). They are Yii core part

fps01 commented 7 years ago

@mtangoo this solution will be work. But we have to observe updates of the main reporitory and pull changes by hands. Let's vote (add reaction to this post). Add +1 - remove dependency or -1 - stay as is.

mtangoo commented 7 years ago

@fps01 it does not have to be manual work, simple PHP callback downloading latest versions can be added to composer for post-install command. see the composer docs on that

mtangoo commented 7 years ago

Here is a sample command that should not be hard to adopt

{
    "scripts": {
        "post-install-packaging": [
            "php -r \"copy('https://github.com/puikinsh/gentelella/blob/master/src/js/custom.js', '@vendor/.../js/custom.js');\""
        ]
    }
}
fps01 commented 7 years ago

@mtangoo An automatic copying can produce collisions between different versions of extensions. For example,

  1. we have a working yii2-gentelella package (ver. 1.a.b) with gentelella package (ver. 1.x.y)
  2. the gentelella is updated (ver 1.x.y+1 or ver 1.x+1.0) and this version has a functional with critical changes
  3. the yii2-gentelella downloads new version and it breaks down some functional

Also we can create an issue at gentelella repository to remove vendor directory. I think it's a prefer way to minify size)

mtangoo commented 7 years ago

In that case the script have to download the release package (version will be locked in there per each release), extract the zip and copy necessary files and then delete the folder. That way we can avoid all those issues and few KBs is better than 90+MB (as those others will be deleted)

But still the idea of not including verndor and let user download them via bower/npm is better so I second opening an issue there

fps01 commented 7 years ago

@mtangoo , @nelsonpoon Work in progress (https://github.com/puikinsh/gentelella/issues/348)