Download the PHP package maxencebeno/webpack-encore-bundle without Composer
On this page you can find all versions of the php package maxencebeno/webpack-encore-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download maxencebeno/webpack-encore-bundle
More information about maxencebeno/webpack-encore-bundle
Files in maxencebeno/webpack-encore-bundle
Package webpack-encore-bundle
Short Description Integration with your Symfony app & Webpack Encore!
License MIT
Informations about the package webpack-encore-bundle
WebpackEncoreBundle: Symfony integration with Webpack Encore!
This bundle allows you to use the splitEntryChunks()
feature
from Webpack Encore
by reading an entrypoints.json
file and helping you render all of
the dynamic script
and link
tags needed.
Install the bundle with:
Configuration
If you're using Symfony Flex, you're done! The recipe will
pre-configure everything you need in the config/packages/webpack_encore.yaml
file:
Usage
The "Split Chunks" functionality in Webpack Encore is enabled by default with the recipe if you install this bundle using Symfony Flex. Otherwise, enable it manually:
When you enable splitEntryChunks()
, instead of just needing 1 script tag
for entry1.js
and 1 link tag for entry1.css
, you may now need multiple
script and link tags. This is because Webpack "splits" your files
into smaller pieces for greater optimization.
To help with this, Encore writes an entrypoints.json
file that contains
all of the files needed for each "entry".
For example, to render all of the script
and link
tags for a specific
"entry" (e.g. entry1
), you can:
Assuming that entry1
required two files to be included - build/vendor~entry1~entry2.js
and build/entry1.js
, then encore_entry_script_tags()
is equivalent to:
If you want more control, you can use the encore_entry_js_files()
and
encore_entry_css_files()
methods to get the list of files needed, then
loop and create the script
and link
tags manually.
Rendering Multiple Times in a Request (e.g. to Generate a PDF)
When you render your script or link tags, the bundle is smart enough
not to repeat the same JavaScript or CSS file within the same request.
This prevents you from having duplicate <link>
or <script>
tags
if you render multiple entries that both rely on the same file.
In some cases, however, you may want to render the script & link tags for the same entry multiple times in a request. For example, if you render multiple Twig templates to create multiple PDF files during a single request.
In that case, before each render, you'll need to "reset" the internal cache so that the bundle re-renders CSS or JS files that it previously rendered. For example, in a controller:
If you have multiple builds, you can also autowire
Symfony\WebpackEncoreBundle\Asset\EntrypointLookupCollectionInterface
and use it to get the EntrypointLookupInterface
object for any build.
All versions of webpack-encore-bundle with dependencies
symfony/asset Version ^3.4 || ^4.0 || ^5.0
symfony/config Version ^3.4 || ^4.0 || ^5.0
symfony/dependency-injection Version ^3.4 || ^4.0 || ^5.0
symfony/http-kernel Version ^3.4 || ^4.0 || ^5.0
symfony/service-contracts Version ^1.0 || ^2.0