{"id":22814466,"url":"https://github.com/68publishers/webpack-encore-bundle","last_synced_at":"2025-04-22T18:39:13.403Z","repository":{"id":56629936,"uuid":"187721564","full_name":"68publishers/webpack-encore-bundle","owner":"68publishers","description":":open_file_folder: Intergration of Symfony's Webpack Encore into Nette Framework","archived":false,"fork":false,"pushed_at":"2024-08-06T01:01:46.000Z","size":91,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-11T11:50:42.300Z","etag":null,"topics":["encore","nette","symfony","webpack","webpack-encore"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/68publishers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-20T22:26:21.000Z","updated_at":"2024-08-06T01:00:17.000Z","dependencies_parsed_at":"2023-01-22T17:16:18.898Z","dependency_job_id":null,"html_url":"https://github.com/68publishers/webpack-encore-bundle","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/68publishers%2Fwebpack-encore-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/68publishers%2Fwebpack-encore-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/68publishers%2Fwebpack-encore-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/68publishers%2Fwebpack-encore-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/68publishers","download_url":"https://codeload.github.com/68publishers/webpack-encore-bundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229388360,"owners_count":18065252,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["encore","nette","symfony","webpack","webpack-encore"],"created_at":"2024-12-12T13:09:01.273Z","updated_at":"2024-12-12T13:09:01.931Z","avatar_url":"https://github.com/68publishers.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eNette integration with Webpack Encore\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003eThis package allows you to use the \u003ccode\u003esplitEntryChunks()\u003c/code\u003e feature from \u003ca href=\"https://symfony.com/doc/current/frontend.html\"\u003eWebpack Encore\u003c/a\u003e by reading an \u003ccode\u003eentrypoints.json\u003c/code\u003e file and helping you render all of the dynamic \u003ccode\u003escript\u003c/code\u003e and \u003ccode\u003elink\u003c/code\u003e tags needed.\u003c/p\u003e\n\u003cp align=\"center\"\u003eInspired by \u003ca href=\"https://github.com/symfony/webpack-encore-bundle\"\u003esymfony/webpack-encore-bundle\u003c/a\u003e\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/68publishers/webpack-encore-bundle/actions\"\u003e\u003cimg alt=\"Checks\" src=\"https://badgen.net/github/checks/68publishers/webpack-encore-bundle/master\"\u003e\u003c/a\u003e\n\u003ca href=\"https://coveralls.io/github/68publishers/webpack-encore-bundle?branch=master\"\u003e\u003cimg alt=\"Coverage Status\" src=\"https://coveralls.io/repos/github/68publishers/webpack-encore-bundle/badge.svg?branch=master\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/68publishers/webpack-encore-bundle\"\u003e\u003cimg alt=\"Total Downloads\" src=\"https://badgen.net/packagist/dt/68publishers/webpack-encore-bundle\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/68publishers/webpack-encore-bundle\"\u003e\u003cimg alt=\"Latest Version\" src=\"https://badgen.net/packagist/v/68publishers/webpack-encore-bundle\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/68publishers/webpack-encore-bundle\"\u003e\u003cimg alt=\"PHP Version\" src=\"https://badgen.net/packagist/php/68publishers/webpack-encore-bundle\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Installation\n\nThe best way to install 68publishers/webpack-encore-bundle is using Composer:\n\n```sh\n$ composer require 68publishers/webpack-encore-bundle\n```\n\nthe package requires integration with [symfony/asset](https://github.com/symfony/asset).\nWe recommend using of our package [68publishers/asset](https://github.com/68publishers/asset), but you can use your own integration.\n\n## Configuration\n\nFirst, register a compiler extension into DIC:\n\n```neon\nextensions:\n\tencore: SixtyEightPublishers\\WebpackEncoreBundle\\Bridge\\Nette\\DI\\WebpackEncoreBundleExtension\n```\n\n### Minimal Configuration\n\n```neon\nencore:\n\t# The path where Encore is building the assets - i.e. Encore.setOutputPath()\n\toutput_path: %wwwDir%/public/build\n```\n\nYou must also set the manifest path for the Asset component.\nIf you are using [68publishers/asset](https://github.com/68publishers/asset), the configuration might look something like this:\n\n```neon\nasset:\n\tjson_manifest_path: %wwwDir%/public/build/manifest.json\n```\n\n### Multiple builds\n\n```neon\nencore:\n\toutput_path: null # or just omit this option\n\tbuilds:\n\t\tfrontend: %wwwDir%/public/frontend/build\n\t\tanother: %wwwDir%/public/another/build\n```\n\n### Default attributes\n\n```neon\nencore:\n\t# if using Encore.enableIntegrityHashes() and need the crossorigin attribute. Allowed values are NULL, 'anonymous' or 'use-credentials'. Default is NULL.\n\tcrossorigin: anonymous\n\n\t# Set attributes that will be rendered on all script tags\n\tscript_attributes:\n\t\tdefer: yes\n\t\treferrerpolicy: origin\n\n\t# Set attributes that will be rendered on all link tags\n\tlink_attributes:\n\t\treferrerpolicy: origin\n```\n\n### HTTP Preload\n\nAll scripts and styles will be preloaded via [HTTP2 header `Link`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Link) if the option is enabled.\n\n```neon\nencore:\n\tpreload: yes\n```\n\n### Entrypoints.json cache\n\nThe parsed content of the `entrypoints.json` file can be cached for faster loading.\nIt is necessary to have the application integrated with [`symfony/console`](https://github.com/symfony/console) for this feature to work, as the cache must be created manually using the console command.\n\n```neon\nencore:\n\tcache: yes # you can use %debugMode%\n```\n\nTo generate the cache, run the following command:\n\n```sh\n$ bin/console encore:warmup-cache\n```\n\nThe cache file will be generated as `%wwwDir%//cache/webpack_encore.cache.php`.\n\n:exclamation: Cache must be regenerated when the entrypoints.json changes. Use the option in a production environment only and run the command within an application build.\n\n### Strict mode\n\nBy default, if we want to render tags for an entry that is not defined in the `entrypoints.json`, the application throws an `EntryPointNotFoundException` exception.\nYou can disable this behaviour:\n\n```neon\nencore:\n\tstrict_mode: no\n```\n\n## Usage in Latte templates\n\nScript and Links tags should be rendered with macros `encore_js` and `encore_css`:\n\n```latte\n{*\n    {encore_js string $entryName, ?string $packageName, ?string $entrypointName, array $extraAttributes = []}\n    {encore_css string $entryName, ?string $packageName, ?string $entrypointName, array $extraAttributes = []}\n*}\n\n{block js}\n    {include parent}\n\n    {encore_js 'entry1'}\n    {* if you are using multiple builds *}\n    {encore_js, 'entry1', null, 'frontend'}\n    {* if you want to pass extra attributes *}\n    {encore_js 'entry1' null, null, ['async' =\u003e true]}\n{/block}\n\n{block stylesheets}\n    {include parent}\n\n    {encore_css 'entry1'}\n    {* if you are using multiple builds *}\n    {encore_css, 'entry1', null, 'frontend'}\n    {* if you want to pass extra attributes *}\n    {encore_css 'entry1' null, null, ['hreflang' =\u003e 'en']}\n{/block}\n```\n\nIf for some reason you need manual access to individual file names, you can use the following Latte functions:\n\n```latte\n{*\n    {encore_js_files(string $entryName, ?string $entrypointName): array}\n    {encore_css_files(string $entryName, ?string $entrypointName): array}\n    {encore_entry_exists(string $entryName, ?string $entrypointName): bool}\n*}\n\n{foreach encore_js_files('entry1') as $file}\n    {var $asset = asset($file)}\n{/foreach}\n\n{foreach encore_css_files('entry1') as $file}\n    {var $asset = asset($file)}\n{/foreach}\n\n{* Render tags for entry `entry2` only if the entry exists (prevents an exception throwing in a strict mode) *}\n{if encore_entry_exists('entry2')}\n    {encore_js 'entry2'}\n{/if}\n```\n\n## Events\n\nIf your application is integrated with [symfony/event-dispatcher](https://github.com/symfony/event-dispatcher), you can handle the event `RenderAssetTagEvent` that is called when a script or link tag is generated.\n\n```php\nnamespace App\\EventSubscriber;\n\nuse Symfony\\Component\\EventDispatcher\\EventSubscriberInterface;\nuse SixtyEightPublishers\\WebpackEncoreBundle\\Event\\RenderAssetTagEvent;\n\nfinal class ScriptNonceSubscriber implements EventSubscriberInterface\n{\n    public static function getSubscribedEvents()\n    {\n        return [\n            RenderAssetTagEvent::class =\u003e 'onRenderAssetTag',\n        ];\n    }\n\n    public function onRenderAssetTag(RenderAssetTagEvent $event): void\n    {\n        if ($event-\u003eisScriptTag()) {\n            $event-\u003esetAttribute('nonce', 'lookup nonce');\n        }\n    }\n}\n```\n\n## Contributing\n\nBefore opening a pull request, please check your changes using the following commands\n\n```bash\n$ make init # to pull and start all docker images\n\n$ make cs.check\n$ make stan\n$ make tests.all\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F68publishers%2Fwebpack-encore-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F68publishers%2Fwebpack-encore-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F68publishers%2Fwebpack-encore-bundle/lists"}