-
Notifications
You must be signed in to change notification settings - Fork 68
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
[Theme] consider webpack-encore #3601
Comments
This is straightforward we do not have to refactor anything. After installing we will have assets dir in our src folder where we can place all core assets sources.
This way we can include jquery as well and all needed libraries. |
Hi so I have played a bit with it and I feel safer now in this matter so first what we need.
Core assets can be declared directly src/assets/js and /css. All assets can be managed and processed by loaders. Php bundle which needs to be installed, enabled and then it will provide additional integration like twig etc.. I have not tested this yet. I'm not sure how to handle modules and theme assets yet including bootstrap etc.. |
This would also include bootstrap, font awesome, and so on, right?
Any documentation / feature overview?
Whenever a module/theme is activated/deactivated webpack would be renewed I guess. It needs to scan/fetch all bundles to include their stuff. How does plain Symfony handle this? Let each bundle process encore for itself only? |
Ok so So let's recap it is a big change because it introduces another ecosystem. We will eventually move all php bundles that are asset related like bootstrap, polyfils and we will move it to encore as well zikula core config js etc. Now let's say we have done that and we want to include jquery globally (there is a way to include it and call it when needed but we are not ready yet ;). So yarn use in a similar way to composer so yarn install jquery (there are lock files and etc.. just like composer for php) apart from yarn there is npm which is similar. Ok so we create src/assets/js/global.js and src/assets/css/global.css we can use app or common whatever. Then we point to those files in webpack_config. (i will include my messed up configs) There is a lot to learn as this is js environment and there is a lot of it the way they bundle and load and manage packages. For sure it is Symfony way and the difference is only that in 4x you would install it all via Flex what we do is we are doing that manually. Below I have played with ckeditor and twigjs and underscore, webpack_config loads encore and encore is configured to load all other installed packages and global.js where I'm adding those packages to the window. webpack_config
global.js
|
Does encore already provide namespaces for Symfony bundles (like |
I do not think so... hmm might be because encore can scan all src and load whatever just need to configure or create loader and those loaders are like |
I think for '@zikulacontentmodule/my-module-specific-module' you would have to create, an npm package, but that twig load from webpack php bundle might use some sort of namespace that you can call it. We might be able to create simple loader that is scanning all themes and modules and then load them... |
Convention directories in Symfony:
See https://symfony.com/doc/current/frontend/encore/simple-example.html#configuring-encore-webpack for example. |
@craigh hmm... this is what I was referring to in #4032 So no assets compilation minification etc during module install - we can copy module assets to web folder but that is it - no webpack magic. The only place where we can and we should use webpack atm is to manage core assets and js libraries that are supplied with the core so... jquery, jquery ui all core css, js and core modules as well...polyfils etc.. these files will be compiled minified and dumped in web/build directory... This way we can provide default js toolbox for module developers so things like twig js, moment, maybe a lightweight framework, something more advanced than jquery to play with... |
http://symfony.com/blog/introducing-webpack-encore-for-asset-management
https://github.com/symfony/webpack-encore
http://symfony.com/doc/current/frontend.html
The text was updated successfully, but these errors were encountered: