Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How ICMS 2.0 should manage front-end assets? #134

Closed
MekDrop opened this issue Jan 29, 2018 · 16 comments
Closed

How ICMS 2.0 should manage front-end assets? #134

MekDrop opened this issue Jan 29, 2018 · 16 comments

Comments

@MekDrop
Copy link
Member

MekDrop commented Jan 29, 2018

We have composer for all PHP libraries, but what about front-end libraries like jquery? What we should use?

From what I know, we have right now two main options with few suboptions:

  1. Use composer for that:
    a) fxp/composer-asset-plugin - most popular variant, however it needs to be installed globally on the server
    b) beelab/bowerphp - doesn't need global install, but doesn't work with all assets and also only bower, which looses popularity
    c) foxy/foxy - acts more like proxy between composer and npm
  2. Use native like many standalone networks does. I think this is most elegant way however I'm not sure how to make possibility to add it easy into modules. And another problem - not every shared hosting has preinstalled such tool.
@MekDrop MekDrop added this to the 2.0.0 milestone Jan 29, 2018
@fiammybe
Copy link
Member

fiammybe commented Jan 29, 2018 via email

@MekDrop
Copy link
Member Author

MekDrop commented Jan 29, 2018

My short research: all popular cms'es just puts assets into folder and that's it. No specitific assets handling. But I'm not sure if this is a good way.

  1. I think it would be possible to offer 3rd option. We could use standard npm tools and for all users that doesn't have npm or yarn installed on server we could provide cloud based service (we download, build all assets on our server and than upload result to users server with some kind of rest api).

For building operations we would need server with shell access. I'm not sure if we such have right now. If no, I don't think so that will cost much but if I'm wrong (that means that such service would be on big demand) we could maybe start offer paid services for everyone who doesn't like to wait much more.

@fiammybe
Copy link
Member

fiammybe commented Jan 29, 2018 via email

@MekDrop
Copy link
Member Author

MekDrop commented Jan 30, 2018

Most JS libraries could be resolved with WebPack. Also, it lets include different assets versions in same website without conflicts. Laravel Mix is easy way to walk into WebPack world. So, maybe we could move our JS core libs to webpack with some legacy bindings and for module authors just ask them to use webpack for prebuild their assets and then load their builds (they will need to include prebuilded JS files in their views)? Later we could implement a bit better way for doing such things.

@fiammybe
Copy link
Member

fiammybe commented Jan 31, 2018 via email

@MekDrop
Copy link
Member Author

MekDrop commented Feb 1, 2018

I think we should postphone this one question. I know how to implement this but this needs some free time. Maybe at the first we need move as much from core to composer libs as we can - later it would be easier to make some improvements to core

@MekDrop
Copy link
Member Author

MekDrop commented Feb 12, 2018

I think easiest solution for us at least for now would be to use kriswallsmith/assetic. It's impossible with it download assets but it's possible to include front-end assets and compile, minify if is needed from any path. So, I think it would be good enough for us for a while.

@MekDrop
Copy link
Member Author

MekDrop commented Feb 12, 2018

It seems DYFeng/composer-asset-plugin that tries to fix many issues that fxp/composer-asset-plugin has, so probably this could be a good tool for us to download module and main front-end assets.

@MekDrop
Copy link
Member Author

MekDrop commented Feb 13, 2018

DYFeng/composer-asset-plugin seems doesn't work yet.

Xoops has assets manager. It works. But it is not usable outside their CMS. It has good ideas but not so good implementation. So, that's why I think best way it would be a create composer lib and include it in our CMS.

How I think this lib should work:

  • automatically optimize images in public assets folder
  • minimize javascript and css files in public folders
  • automatically compile less, scss, coffeescript, dart, handlebars, react jsx, stylus, typescript, gss files automatically
  • when compiling assets add prefix by module
  • provides methods:
    • to get url to asset by filename
    • to set/get assets public dir
    • to update assets for module (it would be invoked when module is installed or updated)
    • to delete assets for module (it should be deleted when module is uninstalled)

@MekDrop
Copy link
Member Author

MekDrop commented Mar 2, 2018

Based on ziadoz/awesome-php#742 it seems that kriswallsmith/assetic probably will not be updated ever. So, it's not a good choice for us :/

@MekDrop
Copy link
Member Author

MekDrop commented Mar 7, 2018

nodejs-installer composer plugin that installs npm in vendor folder. So, NodeJS doesn't need to be installed on the server to be able to use it for assets.

One possible problem here - what to do if exec PHP command is disabled? In that case we have npm but we can't use it. Would be this a major problem for us?

@MekDrop
Copy link
Member Author

MekDrop commented Mar 8, 2018

asset-packagist.org is another way how we could include assets for modules/cms. It's a repository that lets download many popular front-end assets with composer without any plugins. Looks good, but problem with it is that we everything goes to vendor and with #159 vendor is no more a public folder. Another problem is that it doesn't provides ant tools how to work with ES modules and these things now use many front-end developers.

@MekDrop
Copy link
Member Author

MekDrop commented Mar 23, 2018

After some investigation I think I have figure out how assets management for ICMS should work. imponeer/composer-yarn-installer downloads and installs yarn if is not available on system. foxy/foxy fetches package.json from modules and updates local node modules installation. Than another not yet available composer plugin would find modules with encore.config.js. This plugin will merge all these JS files and starts Symfony Encore that builds JS modules. These modules will be able to be included on website. Of course if anyone would like to use old style script inclusion, they could use if they want. Probably > 90% old style scripts would work.

Too not run always composer install or composer update commands for updating assets two commands will be available:

  • composer assets:update - one time assets compile
  • composer assets:watch - stars runner that watch for assets changes and recompiles if something changes.

@fiammybe
Copy link
Member

The issue I have here is that you need a web host that needs command-line access, and it makes things much more complicated.
I would be in favor of keeping our current way of handling the javascript assets for now, and not making this a requirement for 2.0.

In my view, the front-end developer has the responsibility to make the build, and then push the finalised product to the CMS. There are too many frontend build pipelines (Ruby, node.js, rust, bower, gulp, ...) around, and we shouldn't limit the options for frontend development (theming, javascript framework integration), because things change so fast in that domain, that it will be impossible to stay up to date.

@MekDrop
Copy link
Member Author

MekDrop commented Dec 14, 2019

Maybe pipelines are too much for us right now, but I would like at least add more secure assets instaltion model. Right now including in module folder as works now exposes also other files that shouldn't be accessible.

@github-actions
Copy link

This issue was automatically marked as stale

@github-actions github-actions bot added the stale label May 28, 2021
@ImpressCMS ImpressCMS locked and limited conversation to collaborators Oct 13, 2021
@MekDrop MekDrop closed this as completed Oct 13, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

2 participants