Skip to content

[WebpackEncore][StimulusBundle] Add recipe for WebpackEncore 7.0 - #1542

Merged
fabpot merged 1 commit into
symfony:mainfrom
Kocal:webpack-encore-7.0
Jun 25, 2026
Merged

[WebpackEncore][StimulusBundle] Add recipe for WebpackEncore 7.0#1542
fabpot merged 1 commit into
symfony:mainfrom
Kocal:webpack-encore-7.0

Conversation

@Kocal

@Kocal Kocal commented Jun 22, 2026

Copy link
Copy Markdown
Member
Q A
License MIT
Doc issue/PR symfony/symfony-docs#22403

Related to https://github.com/symfony/webpack-encore/releases/tag/v7.0.0

It's 2.1 recipe + JS dependencies upgrade + moving webpack config file to ESM+await

@symfony-recipes-bot
symfony-recipes-bot enabled auto-merge (squash) June 22, 2026 06:56
@symfony-recipes-bot

symfony-recipes-bot commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the PR 😍

How to test these changes in your application

  1. Define the SYMFONY_ENDPOINT environment variable:

    # On Unix-like (BSD, Linux and macOS)
    export SYMFONY_ENDPOINT=https://raw.githubusercontent.com/symfony/recipes/flex/pull-1542/index.json
    # On Windows
    SET SYMFONY_ENDPOINT=https://raw.githubusercontent.com/symfony/recipes/flex/pull-1542/index.json
  2. Install the package(s) related to this recipe:

    composer req symfony/flex
    composer req 'symfony/stimulus-bundle:^2.25' 'symfony/webpack-encore-bundle:^2.2'
  3. Don't forget to unset the SYMFONY_ENDPOINT environment variable when done:

    # On Unix-like (BSD, Linux and macOS)
    unset SYMFONY_ENDPOINT
    # On Windows
    SET SYMFONY_ENDPOINT=

Diff between recipe versions

In order to help with the review stage, I'm in charge of computing the diff between the various versions of patched recipes.
I'm going keep this comment up to date with any updates of the attached patch.

symfony/stimulus-bundle

2.8 vs 2.9
diff --git a/symfony/stimulus-bundle/2.9/assets/bootstrap.js b/symfony/stimulus-bundle/2.9/assets/bootstrap.js
new file mode 100644
index 00000000..2689398a
--- /dev/null
+++ b/symfony/stimulus-bundle/2.9/assets/bootstrap.js
@@ -0,0 +1,2 @@
+// register any custom, 3rd party controllers here
+// app.register('some_controller_name', SomeImportedController);
diff --git a/symfony/stimulus-bundle/2.9/assets/controllers/hello_controller.js b/symfony/stimulus-bundle/2.9/assets/controllers/hello_controller.js
new file mode 100644
index 00000000..e847027b
--- /dev/null
+++ b/symfony/stimulus-bundle/2.9/assets/controllers/hello_controller.js
@@ -0,0 +1,16 @@
+import { Controller } from '@hotwired/stimulus';
+
+/*
+ * This is an example Stimulus controller!
+ *
+ * Any element with a data-controller="hello" attribute will cause
+ * this controller to be executed. The name "hello" comes from the filename:
+ * hello_controller.js -> "hello"
+ *
+ * Delete this file or adapt it for your use!
+ */
+export default class extends Controller {
+    connect() {
+        this.element.textContent = 'Hello Stimulus! Edit me in assets/controllers/hello_controller.js';
+    }
+}
diff --git a/symfony/stimulus-bundle/2.9/assets/controllers.json b/symfony/stimulus-bundle/2.9/assets/controllers.json
new file mode 100644
index 00000000..a1c6e90c
--- /dev/null
+++ b/symfony/stimulus-bundle/2.9/assets/controllers.json
@@ -0,0 +1,4 @@
+{
+    "controllers": [],
+    "entrypoints": []
+}
diff --git a/symfony/stimulus-bundle/2.8/manifest.json b/symfony/stimulus-bundle/2.9/manifest.json
index ff66e874..2e3358cd 100644
--- a/symfony/stimulus-bundle/2.8/manifest.json
+++ b/symfony/stimulus-bundle/2.9/manifest.json
@@ -2,5 +2,67 @@
     "bundles": {
         "Symfony\\UX\\StimulusBundle\\StimulusBundle": ["all"]
     },
-    "aliases": ["stimulus", "stimulus-bundle"]
+    "copy-from-recipe": {
+        "assets/": "assets/"
+    },
+    "aliases": ["stimulus", "stimulus-bundle"],
+    "conflict": {
+        "symfony/webpack-encore-bundle": "<2.0",
+        "symfony/flex": "<1.20.0 || >=2.0.0,<2.3.0"
+    },
+    "add-lines": [
+        {
+            "file": "webpack.config.js",
+            "content": [
+                "",
+                "    // enables the Symfony UX Stimulus bridge (used in assets/bootstrap.js)",
+                "    .enableStimulusBridge('./assets/controllers.json')"
+            ],
+            "position": "after_target",
+            "target": ".splitEntryChunks()"
+        },
+        {
+            "file": "assets/app.js",
+            "content": [
+                "import './bootstrap.js';"
+            ],
+            "position": "top",
+            "warn_if_missing": true
+        },
+        {
+            "file": "assets/bootstrap.js",
+            "content": [
+                "import { startStimulusApp } from '@symfony/stimulus-bridge';",
+                "",
+                "// Registers Stimulus controllers from controllers.json and in the controllers/ directory",
+                "export const app = startStimulusApp(require.context(",
+                "    '@symfony/stimulus-bridge/lazy-controller-loader!./controllers',",
+                "    true,",
+                "    /\\.[jt]sx?$/",
+                "));"
+            ],
+            "position": "top",
+            "requires": "symfony/webpack-encore-bundle"
+        },
+        {
+            "file": "assets/bootstrap.js",
+            "content": [
+                "import { startStimulusApp } from '@symfony/stimulus-bundle';",
+                "",
+                "const app = startStimulusApp();"
+            ],
+            "position": "top",
+            "requires": "symfony/asset-mapper"
+        },
+        {
+            "file": "templates/base.html.twig",
+            "content": [
+                "            {{ ux_controller_link_tags() }}"
+            ],
+            "position": "after_target",
+            "target": "{% block stylesheets %}",
+            "warn_if_missing": true,
+            "requires": "symfony/asset-mapper"
+        }
+    ]
 }
2.9 vs 2.13
diff --git a/symfony/stimulus-bundle/2.9/manifest.json b/symfony/stimulus-bundle/2.13/manifest.json
index 2e3358cd..adbf1ec8 100644
--- a/symfony/stimulus-bundle/2.9/manifest.json
+++ b/symfony/stimulus-bundle/2.13/manifest.json
@@ -53,16 +53,6 @@
             ],
             "position": "top",
             "requires": "symfony/asset-mapper"
-        },
-        {
-            "file": "templates/base.html.twig",
-            "content": [
-                "            {{ ux_controller_link_tags() }}"
-            ],
-            "position": "after_target",
-            "target": "{% block stylesheets %}",
-            "warn_if_missing": true,
-            "requires": "symfony/asset-mapper"
         }
     ]
 }
2.13 vs 2.20
diff --git a/symfony/stimulus-bundle/2.20/assets/controllers/csrf_protection_controller.js b/symfony/stimulus-bundle/2.20/assets/controllers/csrf_protection_controller.js
new file mode 100644
index 00000000..511fffa5
--- /dev/null
+++ b/symfony/stimulus-bundle/2.20/assets/controllers/csrf_protection_controller.js
@@ -0,0 +1,81 @@
+const nameCheck = /^[-_a-zA-Z0-9]{4,22}$/;
+const tokenCheck = /^[-_/+a-zA-Z0-9]{24,}$/;
+
+// Generate and double-submit a CSRF token in a form field and a cookie, as defined by Symfony's SameOriginCsrfTokenManager
+// Use `form.requestSubmit()` to ensure that the submit event is triggered. Using `form.submit()` will not trigger the event
+// and thus this event-listener will not be executed.
+document.addEventListener('submit', function (event) {
+    generateCsrfToken(event.target);
+}, true);
+
+// When @hotwired/turbo handles form submissions, send the CSRF token in a header in addition to a cookie
+// The `framework.csrf_protection.check_header` config option needs to be enabled for the header to be checked
+document.addEventListener('turbo:submit-start', function (event) {
+    const h = generateCsrfHeaders(event.detail.formSubmission.formElement);
+    Object.keys(h).map(function (k) {
+        event.detail.formSubmission.fetchRequest.headers[k] = h[k];
+    });
+});
+
+// When @hotwired/turbo handles form submissions, remove the CSRF cookie once a form has been submitted
+document.addEventListener('turbo:submit-end', function (event) {
+    removeCsrfToken(event.detail.formSubmission.formElement);
+});
+
+export function generateCsrfToken (formElement) {
+    const csrfField = formElement.querySelector('input[data-controller="csrf-protection"], input[name="_csrf_token"]');
+
+    if (!csrfField) {
+        return;
+    }
+
+    let csrfCookie = csrfField.getAttribute('data-csrf-protection-cookie-value');
+    let csrfToken = csrfField.value;
+
+    if (!csrfCookie && nameCheck.test(csrfToken)) {
+        csrfField.setAttribute('data-csrf-protection-cookie-value', csrfCookie = csrfToken);
+        csrfField.defaultValue = csrfToken = btoa(String.fromCharCode.apply(null, (window.crypto || window.msCrypto).getRandomValues(new Uint8Array(18))));
+    }
+    csrfField.dispatchEvent(new Event('change', { bubbles: true }));
+
+    if (csrfCookie && tokenCheck.test(csrfToken)) {
+        const cookie = csrfCookie + '_' + csrfToken + '=' + csrfCookie + '; path=/; samesite=strict';
+        document.cookie = window.location.protocol === 'https:' ? '__Host-' + cookie + '; secure' : cookie;
+    }
+}
+
+export function generateCsrfHeaders (formElement) {
+    const headers = {};
+    const csrfField = formElement.querySelector('input[data-controller="csrf-protection"], input[name="_csrf_token"]');
+
+    if (!csrfField) {
+        return headers;
+    }
+
+    const csrfCookie = csrfField.getAttribute('data-csrf-protection-cookie-value');
+
+    if (tokenCheck.test(csrfField.value) && nameCheck.test(csrfCookie)) {
+        headers[csrfCookie] = csrfField.value;
+    }
+
+    return headers;
+}
+
+export function removeCsrfToken (formElement) {
+    const csrfField = formElement.querySelector('input[data-controller="csrf-protection"], input[name="_csrf_token"]');
+
+    if (!csrfField) {
+        return;
+    }
+
+    const csrfCookie = csrfField.getAttribute('data-csrf-protection-cookie-value');
+
+    if (tokenCheck.test(csrfField.value) && nameCheck.test(csrfCookie)) {
+        const cookie = csrfCookie + '_' + csrfField.value + '=0; path=/; samesite=strict; max-age=0';
+
+        document.cookie = window.location.protocol === 'https:' ? '__Host-' + cookie + '; secure' : cookie;
+    }
+}
+
+/* stimulusFetch: 'lazy' */
+export default 'csrf-protection-controller';
diff --git a/symfony/stimulus-bundle/2.13/manifest.json b/symfony/stimulus-bundle/2.20/manifest.json
index adbf1ec8..277af529 100644
--- a/symfony/stimulus-bundle/2.13/manifest.json
+++ b/symfony/stimulus-bundle/2.20/manifest.json
@@ -7,6 +7,8 @@
     },
     "aliases": ["stimulus", "stimulus-bundle"],
     "conflict": {
+        "symfony/framework-bundle": "<7.2",
+        "symfony/security-csrf": "<7.2",
         "symfony/webpack-encore-bundle": "<2.0",
         "symfony/flex": "<1.20.0 || >=2.0.0,<2.3.0"
     },
2.20 vs 2.24
diff --git a/symfony/stimulus-bundle/2.20/assets/bootstrap.js b/symfony/stimulus-bundle/2.24/assets/stimulus_bootstrap.js
similarity index 100%
rename from symfony/stimulus-bundle/2.20/assets/bootstrap.js
rename to symfony/stimulus-bundle/2.24/assets/stimulus_bootstrap.js
diff --git a/symfony/stimulus-bundle/2.20/manifest.json b/symfony/stimulus-bundle/2.24/manifest.json
index 277af529..786a649f 100644
--- a/symfony/stimulus-bundle/2.20/manifest.json
+++ b/symfony/stimulus-bundle/2.24/manifest.json
@@ -17,7 +17,7 @@
             "file": "webpack.config.js",
             "content": [
                 "",
-                "    // enables the Symfony UX Stimulus bridge (used in assets/bootstrap.js)",
+                "    // enables the Symfony UX Stimulus bridge (used in assets/stimulus_bootstrap.js)",
                 "    .enableStimulusBridge('./assets/controllers.json')"
             ],
             "position": "after_target",
@@ -26,13 +26,13 @@
         {
             "file": "assets/app.js",
             "content": [
-                "import './bootstrap.js';"
+                "import './stimulus_bootstrap.js';"
             ],
             "position": "top",
             "warn_if_missing": true
         },
         {
-            "file": "assets/bootstrap.js",
+            "file": "assets/stimulus_bootstrap.js",
             "content": [
                 "import { startStimulusApp } from '@symfony/stimulus-bridge';",
                 "",
@@ -47,7 +47,7 @@
             "requires": "symfony/webpack-encore-bundle"
         },
         {
-            "file": "assets/bootstrap.js",
+            "file": "assets/stimulus_bootstrap.js",
             "content": [
                 "import { startStimulusApp } from '@symfony/stimulus-bundle';",
                 "",
2.24 vs 2.25
diff --git a/symfony/stimulus-bundle/2.24/manifest.json b/symfony/stimulus-bundle/2.25/manifest.json
index 786a649f..ee04d19a 100644
--- a/symfony/stimulus-bundle/2.24/manifest.json
+++ b/symfony/stimulus-bundle/2.25/manifest.json
@@ -37,11 +37,10 @@
                 "import { startStimulusApp } from '@symfony/stimulus-bridge';",
                 "",
                 "// Registers Stimulus controllers from controllers.json and in the controllers/ directory",
-                "export const app = startStimulusApp(require.context(",
-                "    '@symfony/stimulus-bridge/lazy-controller-loader!./controllers',",
-                "    true,",
-                "    /\\.[jt]sx?$/",
-                "));"
+                "export const app = startStimulusApp(import.meta.webpackContext('@symfony/stimulus-bridge/lazy-controller-loader!./controllers', {",
+                "    recursive: true,",
+                "    regExp: /\\.[jt]sx?$/,",
+                "}));"
             ],
             "position": "top",
             "requires": "symfony/webpack-encore-bundle"

symfony/webpack-encore-bundle

1.0 vs 1.6
diff --git a/symfony/webpack-encore-bundle/1.6/config/packages/test/webpack_encore.yaml b/symfony/webpack-encore-bundle/1.6/config/packages/test/webpack_encore.yaml
new file mode 100644
index 00000000..02a76515
--- /dev/null
+++ b/symfony/webpack-encore-bundle/1.6/config/packages/test/webpack_encore.yaml
@@ -0,0 +1,2 @@
+#webpack_encore:
+#    strict_mode: false
diff --git a/symfony/webpack-encore-bundle/1.0/config/packages/webpack_encore.yaml b/symfony/webpack-encore-bundle/1.6/config/packages/webpack_encore.yaml
index ce02f6b1..a1335c53 100644
--- a/symfony/webpack-encore-bundle/1.0/config/packages/webpack_encore.yaml
+++ b/symfony/webpack-encore-bundle/1.6/config/packages/webpack_encore.yaml
@@ -1,14 +1,25 @@
 webpack_encore:
-    # The path where Encore is building the assets.
-    # This should match Encore.setOutputPath() in webpack.config.js.
+    # The path where Encore is building the assets - i.e. Encore.setOutputPath()
     output_path: '%kernel.project_dir%/public/build'
     # If multiple builds are defined (as shown below), you can disable the default build:
     # output_path: false
 
-    # if using Encore.enableIntegrityHashes() specify the crossorigin attribute value (default: false, or use 'anonymous' or 'use-credentials')
+    # If using Encore.enableIntegrityHashes() and need the crossorigin attribute (default: false, or use 'anonymous' or 'use-credentials')
     # crossorigin: 'anonymous'
 
-    # Cache the entrypoints.json (rebuild Symfony's cache when entrypoints.json changes).
-    # To enable caching for the production environment, creating a webpack_encore.yaml in the config/packages/prod directory with this value set to true
-    # Available in version 1.2
-    #cache: false
+    # Preload all rendered script and link tags automatically via the HTTP/2 Link header
+    # preload: true
+
+    # Throw an exception if the entrypoints.json file is missing or an entry is missing from the data
+    # strict_mode: false
+
+    # If you have multiple builds:
+    # builds:
+        # pass "frontend" as the 3rg arg to the Twig functions
+        # {{ encore_entry_script_tags('entry1', null, 'frontend') }}
+
+        # frontend: '%kernel.project_dir%/public/frontend/build'
+
+    # Cache the entrypoints.json (rebuild Symfony's cache when entrypoints.json changes)
+    # Put in config/packages/prod/webpack_encore.yaml
+    # cache: true
1.6 vs 1.9
diff --git a/symfony/webpack-encore-bundle/1.6/assets/controllers/hello_controller.js b/symfony/webpack-encore-bundle/1.9/assets/controllers/hello_controller.js
index 8c79f65a..e847027b 100644
--- a/symfony/webpack-encore-bundle/1.6/assets/controllers/hello_controller.js
+++ b/symfony/webpack-encore-bundle/1.9/assets/controllers/hello_controller.js
@@ -1,4 +1,4 @@
-import { Controller } from 'stimulus';
+import { Controller } from '@hotwired/stimulus';
 
 /*
  * This is an example Stimulus controller!
diff --git a/symfony/webpack-encore-bundle/1.6/config/packages/assets.yaml b/symfony/webpack-encore-bundle/1.6/config/packages/assets.yaml
deleted file mode 100644
index 051d36dc..00000000
--- a/symfony/webpack-encore-bundle/1.6/config/packages/assets.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
-framework:
-    assets:
-        json_manifest_path: '%kernel.project_dir%/public/build/manifest.json'
diff --git a/symfony/webpack-encore-bundle/1.6/config/packages/prod/webpack_encore.yaml b/symfony/webpack-encore-bundle/1.6/config/packages/prod/webpack_encore.yaml
deleted file mode 100644
index d0b3ba81..00000000
--- a/symfony/webpack-encore-bundle/1.6/config/packages/prod/webpack_encore.yaml
+++ /dev/null
@@ -1,4 +0,0 @@
-#webpack_encore:
-    # Cache the entrypoints.json (rebuild Symfony's cache when entrypoints.json changes)
-    # Available in version 1.2
-    #cache: true
diff --git a/symfony/webpack-encore-bundle/1.6/config/packages/test/webpack_encore.yaml b/symfony/webpack-encore-bundle/1.6/config/packages/test/webpack_encore.yaml
deleted file mode 100644
index 02a76515..00000000
--- a/symfony/webpack-encore-bundle/1.6/config/packages/test/webpack_encore.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
-#webpack_encore:
-#    strict_mode: false
diff --git a/symfony/webpack-encore-bundle/1.6/config/packages/webpack_encore.yaml b/symfony/webpack-encore-bundle/1.9/config/packages/webpack_encore.yaml
index a1335c53..46834f0c 100644
--- a/symfony/webpack-encore-bundle/1.6/config/packages/webpack_encore.yaml
+++ b/symfony/webpack-encore-bundle/1.9/config/packages/webpack_encore.yaml
@@ -4,6 +4,16 @@ webpack_encore:
     # If multiple builds are defined (as shown below), you can disable the default build:
     # output_path: false
 
+    # Set attributes that will be rendered on all script and link tags
+    script_attributes:
+        defer: true
+        # Uncomment (also under link_attributes) if using Turbo Drive
+        # https://turbo.hotwired.dev/handbook/drive#reloading-when-assets-change
+        # 'data-turbo-track': reload
+    # link_attributes:
+        # Uncomment if using Turbo Drive
+        # 'data-turbo-track': reload
+
     # If using Encore.enableIntegrityHashes() and need the crossorigin attribute (default: false, or use 'anonymous' or 'use-credentials')
     # crossorigin: 'anonymous'
 
@@ -23,3 +33,17 @@ webpack_encore:
     # Cache the entrypoints.json (rebuild Symfony's cache when entrypoints.json changes)
     # Put in config/packages/prod/webpack_encore.yaml
     # cache: true
+
+framework:
+    assets:
+        json_manifest_path: '%kernel.project_dir%/public/build/manifest.json'
+
+#when@prod:
+#    webpack_encore:
+#        # Cache the entrypoints.json (rebuild Symfony's cache when entrypoints.json changes)
+#        # Available in version 1.2
+#        cache: true
+
+#when@test:
+#    webpack_encore:
+#        strict_mode: false
diff --git a/symfony/webpack-encore-bundle/1.6/package.json b/symfony/webpack-encore-bundle/1.9/package.json
index ba0e4f41..813010a7 100644
--- a/symfony/webpack-encore-bundle/1.6/package.json
+++ b/symfony/webpack-encore-bundle/1.9/package.json
@@ -1,10 +1,10 @@
 {
     "devDependencies": {
-        "@symfony/stimulus-bridge": "^2.0.0",
-        "@symfony/webpack-encore": "^1.0.0",
+        "@hotwired/stimulus": "^3.0.0",
+        "@symfony/stimulus-bridge": "^3.0.0",
+        "@symfony/webpack-encore": "^1.7.0",
         "core-js": "^3.0.0",
         "regenerator-runtime": "^0.13.2",
-        "stimulus": "^2.0.0",
         "webpack-notifier": "^1.6.0"
     },
     "license": "UNLICENSED",
diff --git a/symfony/webpack-encore-bundle/1.9/post-install.txt b/symfony/webpack-encore-bundle/1.9/post-install.txt
new file mode 100644
index 00000000..6169d37b
--- /dev/null
+++ b/symfony/webpack-encore-bundle/1.9/post-install.txt
@@ -0,0 +1,5 @@
+  * Install Yarn and run yarn install
+
+  * Uncomment the Twig helpers in templates/base.html.twig (they may be already)
+
+  * Start the development server: yarn encore dev-server
1.9 vs 1.10
diff --git a/symfony/webpack-encore-bundle/1.9/config/packages/webpack_encore.yaml b/symfony/webpack-encore-bundle/1.10/config/packages/webpack_encore.yaml
index 46834f0c..4c009ee4 100644
--- a/symfony/webpack-encore-bundle/1.9/config/packages/webpack_encore.yaml
+++ b/symfony/webpack-encore-bundle/1.10/config/packages/webpack_encore.yaml
@@ -25,14 +25,10 @@ webpack_encore:
 
     # If you have multiple builds:
     # builds:
-        # pass "frontend" as the 3rg arg to the Twig functions
-        # {{ encore_entry_script_tags('entry1', null, 'frontend') }}
-
         # frontend: '%kernel.project_dir%/public/frontend/build'
 
-    # Cache the entrypoints.json (rebuild Symfony's cache when entrypoints.json changes)
-    # Put in config/packages/prod/webpack_encore.yaml
-    # cache: true
+        # pass the build name as the 3rd argument to the Twig functions
+        # {{ encore_entry_script_tags('entry1', null, 'frontend') }}
 
 framework:
     assets:
diff --git a/symfony/webpack-encore-bundle/1.9/manifest.json b/symfony/webpack-encore-bundle/1.10/manifest.json
index 84ab3961..39b0363e 100644
--- a/symfony/webpack-encore-bundle/1.9/manifest.json
+++ b/symfony/webpack-encore-bundle/1.10/manifest.json
@@ -8,11 +8,14 @@
         "package.json": "package.json",
         "webpack.config.js": "webpack.config.js"
     },
-    "aliases": ["ux", "encore", "webpack", "webpack-encore"],
+    "aliases": ["encore", "webpack", "webpack-encore"],
     "gitignore": [
         "/node_modules/",
         "/%PUBLIC_DIR%/build/",
         "npm-debug.log",
         "yarn-error.log"
-    ]
+    ],
+    "conflict": {
+        "symfony/framework-bundle": "<5.4"
+    }
 }
diff --git a/symfony/webpack-encore-bundle/1.9/package.json b/symfony/webpack-encore-bundle/1.10/package.json
index 813010a7..ad2eb752 100644
--- a/symfony/webpack-encore-bundle/1.9/package.json
+++ b/symfony/webpack-encore-bundle/1.10/package.json
@@ -1,11 +1,15 @@
 {
     "devDependencies": {
+        "@babel/core": "^7.17.0",
+        "@babel/preset-env": "^7.16.0",
         "@hotwired/stimulus": "^3.0.0",
         "@symfony/stimulus-bridge": "^3.0.0",
-        "@symfony/webpack-encore": "^1.7.0",
-        "core-js": "^3.0.0",
-        "regenerator-runtime": "^0.13.2",
-        "webpack-notifier": "^1.6.0"
+        "@symfony/webpack-encore": "^4.0.0",
+        "core-js": "^3.23.0",
+        "regenerator-runtime": "^0.13.9",
+        "webpack": "^5.74.0",
+        "webpack-cli": "^4.10.0",
+        "webpack-notifier": "^1.15.0"
     },
     "license": "UNLICENSED",
     "private": true,
diff --git a/symfony/webpack-encore-bundle/1.9/post-install.txt b/symfony/webpack-encore-bundle/1.10/post-install.txt
index 6169d37b..e53f05dc 100644
--- a/symfony/webpack-encore-bundle/1.9/post-install.txt
+++ b/symfony/webpack-encore-bundle/1.10/post-install.txt
@@ -1,5 +1,3 @@
   * Install Yarn and run yarn install
 
-  * Uncomment the Twig helpers in templates/base.html.twig (they may be already)
-
   * Start the development server: yarn encore dev-server
diff --git a/symfony/webpack-encore-bundle/1.9/webpack.config.js b/symfony/webpack-encore-bundle/1.10/webpack.config.js
index 056b04aa..408012fa 100644
--- a/symfony/webpack-encore-bundle/1.9/webpack.config.js
+++ b/symfony/webpack-encore-bundle/1.10/webpack.config.js
@@ -11,7 +11,7 @@ Encore
     .setOutputPath('public/build/')
     // public path used by the web server to access the output path
     .setPublicPath('/build')
-    // only needed for CDN's or sub-directory deploy
+    // only needed for CDN's or subdirectory deploy
     //.setManifestKeyPrefix('build/')
 
     /*
@@ -45,14 +45,15 @@ Encore
     // enables hashed filenames (e.g. app.abc123.css)
     .enableVersioning(Encore.isProduction())
 
-    .configureBabel((config) => {
-        config.plugins.push('@babel/plugin-proposal-class-properties');
-    })
+    // configure Babel
+    // .configureBabel((config) => {
+    //     config.plugins.push('@babel/a-babel-plugin');
+    // })
 
-    // enables @babel/preset-env polyfills
+    // enables and configure @babel/preset-env polyfills
     .configureBabelPresetEnv((config) => {
         config.useBuiltIns = 'usage';
-        config.corejs = 3;
+        config.corejs = '3.23';
     })
 
     // enables Sass/SCSS support
1.10 vs 1.17
diff --git a/symfony/webpack-encore-bundle/1.10/package.json b/symfony/webpack-encore-bundle/1.17/package.json
index ad2eb752..e4118728 100644
--- a/symfony/webpack-encore-bundle/1.10/package.json
+++ b/symfony/webpack-encore-bundle/1.17/package.json
@@ -3,8 +3,8 @@
         "@babel/core": "^7.17.0",
         "@babel/preset-env": "^7.16.0",
         "@hotwired/stimulus": "^3.0.0",
-        "@symfony/stimulus-bridge": "^3.0.0",
-        "@symfony/webpack-encore": "^4.0.0",
+        "@symfony/stimulus-bridge": "^4.0.0",
+        "@symfony/webpack-encore": "^5.1.0",
         "core-js": "^3.23.0",
         "regenerator-runtime": "^0.13.9",
         "webpack": "^5.74.0",
1.17 vs 2.0
diff --git a/symfony/webpack-encore-bundle/1.17/assets/app.js b/symfony/webpack-encore-bundle/2.0/assets/app.js
index bb0a6aa1..85065048 100644
--- a/symfony/webpack-encore-bundle/1.17/assets/app.js
+++ b/symfony/webpack-encore-bundle/2.0/assets/app.js
@@ -7,6 +7,3 @@
 
 // any CSS you import will output into a single css file (app.css in this case)
 import './styles/app.css';
-
-// start the Stimulus application
-import './bootstrap';
diff --git a/symfony/webpack-encore-bundle/1.17/assets/bootstrap.js b/symfony/webpack-encore-bundle/1.17/assets/bootstrap.js
deleted file mode 100644
index 4ab2df64..00000000
--- a/symfony/webpack-encore-bundle/1.17/assets/bootstrap.js
+++ /dev/null
@@ -1,11 +0,0 @@
-import { startStimulusApp } from '@symfony/stimulus-bridge';
-
-// Registers Stimulus controllers from controllers.json and in the controllers/ directory
-export const app = startStimulusApp(require.context(
-    '@symfony/stimulus-bridge/lazy-controller-loader!./controllers',
-    true,
-    /\.[jt]sx?$/
-));
-
-// register any custom, 3rd party controllers here
-// app.register('some_controller_name', SomeImportedController);
diff --git a/symfony/webpack-encore-bundle/1.17/assets/controllers/hello_controller.js b/symfony/webpack-encore-bundle/1.17/assets/controllers/hello_controller.js
deleted file mode 100644
index e847027b..00000000
--- a/symfony/webpack-encore-bundle/1.17/assets/controllers/hello_controller.js
+++ /dev/null
@@ -1,16 +0,0 @@
-import { Controller } from '@hotwired/stimulus';
-
-/*
- * This is an example Stimulus controller!
- *
- * Any element with a data-controller="hello" attribute will cause
- * this controller to be executed. The name "hello" comes from the filename:
- * hello_controller.js -> "hello"
- *
- * Delete this file or adapt it for your use!
- */
-export default class extends Controller {
-    connect() {
-        this.element.textContent = 'Hello Stimulus! Edit me in assets/controllers/hello_controller.js';
-    }
-}
diff --git a/symfony/webpack-encore-bundle/1.17/assets/controllers.json b/symfony/webpack-encore-bundle/1.17/assets/controllers.json
deleted file mode 100644
index a1c6e90c..00000000
--- a/symfony/webpack-encore-bundle/1.17/assets/controllers.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
-    "controllers": [],
-    "entrypoints": []
-}
diff --git a/symfony/webpack-encore-bundle/1.17/manifest.json b/symfony/webpack-encore-bundle/2.0/manifest.json
index 39b0363e..086ced83 100644
--- a/symfony/webpack-encore-bundle/1.17/manifest.json
+++ b/symfony/webpack-encore-bundle/2.0/manifest.json
@@ -16,6 +16,27 @@
         "yarn-error.log"
     ],
     "conflict": {
-        "symfony/framework-bundle": "<5.4"
-    }
+        "symfony/framework-bundle": "<5.4",
+        "symfony/flex": "<1.20.0 || >=2.0.0,<2.3.0"
+    },
+    "add-lines": [
+        {
+            "file": "templates/base.html.twig",
+            "content": [
+                "            {{ encore_entry_script_tags('app') }}"
+            ],
+            "position": "after_target",
+            "target": "{% block javascripts %}",
+            "warn_if_missing": true
+        },
+        {
+            "file": "templates/base.html.twig",
+            "content": [
+                "            {{ encore_entry_link_tags('app') }}"
+            ],
+            "position": "after_target",
+            "target": "{% block stylesheets %}",
+            "warn_if_missing": true
+        }
+    ]
 }
diff --git a/symfony/webpack-encore-bundle/1.17/package.json b/symfony/webpack-encore-bundle/2.0/package.json
index e4118728..6e94b165 100644
--- a/symfony/webpack-encore-bundle/1.17/package.json
+++ b/symfony/webpack-encore-bundle/2.0/package.json
@@ -2,14 +2,11 @@
     "devDependencies": {
         "@babel/core": "^7.17.0",
         "@babel/preset-env": "^7.16.0",
-        "@hotwired/stimulus": "^3.0.0",
-        "@symfony/stimulus-bridge": "^4.0.0",
         "@symfony/webpack-encore": "^5.1.0",
-        "core-js": "^3.23.0",
+        "core-js": "^3.38.0",
         "regenerator-runtime": "^0.13.9",
         "webpack": "^5.74.0",
-        "webpack-cli": "^4.10.0",
-        "webpack-notifier": "^1.15.0"
+        "webpack-cli": "^5.1.0"
     },
     "license": "UNLICENSED",
     "private": true,
diff --git a/symfony/webpack-encore-bundle/1.17/post-install.txt b/symfony/webpack-encore-bundle/2.0/post-install.txt
index e53f05dc..d0ca6c4b 100644
--- a/symfony/webpack-encore-bundle/1.17/post-install.txt
+++ b/symfony/webpack-encore-bundle/2.0/post-install.txt
@@ -1,3 +1,9 @@
-  * Install Yarn and run yarn install
+  * Install NPM and run npm install
 
-  * Start the development server: yarn encore dev-server
+  * Compile your assets for development: npm run dev
+  
+  * Compile your assets for development and watch for any modifications: npm run watch
+  
+  * Or start the development server: npm run dev-server
+  
+  * Compile your assets for production: npm run build
diff --git a/symfony/webpack-encore-bundle/1.17/webpack.config.js b/symfony/webpack-encore-bundle/2.0/webpack.config.js
index 408012fa..391fd7a1 100644
--- a/symfony/webpack-encore-bundle/1.17/webpack.config.js
+++ b/symfony/webpack-encore-bundle/2.0/webpack.config.js
@@ -22,9 +22,6 @@ Encore
      */
     .addEntry('app', './assets/app.js')
 
-    // enables the Symfony UX Stimulus bridge (used in assets/bootstrap.js)
-    .enableStimulusBridge('./assets/controllers.json')
-
     // When enabled, Webpack "splits" your files into smaller pieces for greater optimization.
     .splitEntryChunks()
 
@@ -40,7 +37,10 @@ Encore
      * https://symfony.com/doc/current/frontend.html#adding-more-features
      */
     .cleanupOutputBeforeBuild()
-    .enableBuildNotifications()
+
+    // Displays build status system notifications to the user
+    // .enableBuildNotifications()
+
     .enableSourceMaps(!Encore.isProduction())
     // enables hashed filenames (e.g. app.abc123.css)
     .enableVersioning(Encore.isProduction())
@@ -53,7 +53,7 @@ Encore
     // enables and configure @babel/preset-env polyfills
     .configureBabelPresetEnv((config) => {
         config.useBuiltIns = 'usage';
-        config.corejs = '3.23';
+        config.corejs = '3.38';
     })
 
     // enables Sass/SCSS support
2.0 vs 2.1
diff --git a/symfony/webpack-encore-bundle/2.0/package.json b/symfony/webpack-encore-bundle/2.1/package.json
index 6e94b165..6f96f230 100644
--- a/symfony/webpack-encore-bundle/2.0/package.json
+++ b/symfony/webpack-encore-bundle/2.1/package.json
@@ -2,11 +2,11 @@
     "devDependencies": {
         "@babel/core": "^7.17.0",
         "@babel/preset-env": "^7.16.0",
-        "@symfony/webpack-encore": "^5.1.0",
+        "@symfony/webpack-encore": "^6.0.0",
         "core-js": "^3.38.0",
         "regenerator-runtime": "^0.13.9",
-        "webpack": "^5.74.0",
-        "webpack-cli": "^5.1.0"
+        "webpack": "^5.72",
+        "webpack-cli": "^6.0.0"
     },
     "license": "UNLICENSED",
     "private": true,
2.1 vs 2.2
diff --git a/symfony/webpack-encore-bundle/2.1/package.json b/symfony/webpack-encore-bundle/2.2/package.json
index 6f96f230..4b762134 100644
--- a/symfony/webpack-encore-bundle/2.1/package.json
+++ b/symfony/webpack-encore-bundle/2.2/package.json
@@ -1,12 +1,13 @@
 {
     "devDependencies": {
-        "@babel/core": "^7.17.0",
-        "@babel/preset-env": "^7.16.0",
-        "@symfony/webpack-encore": "^6.0.0",
-        "core-js": "^3.38.0",
+        "@babel/core": "^8.0.0",
+        "@babel/preset-env": "^8.0.0",
+        "@symfony/webpack-encore": "^7.0.0",
+        "babel-plugin-polyfill-corejs3": "^1.0.0",
+        "core-js": "^3.49.0",
         "regenerator-runtime": "^0.13.9",
-        "webpack": "^5.72",
-        "webpack-cli": "^6.0.0"
+        "webpack": "^5.82",
+        "webpack-cli": "^7.0.0"
     },
     "license": "UNLICENSED",
     "private": true,
diff --git a/symfony/webpack-encore-bundle/2.1/webpack.config.js b/symfony/webpack-encore-bundle/2.2/webpack.config.js
index 391fd7a1..cc872fe2 100644
--- a/symfony/webpack-encore-bundle/2.1/webpack.config.js
+++ b/symfony/webpack-encore-bundle/2.2/webpack.config.js
@@ -1,4 +1,4 @@
-const Encore = require('@symfony/webpack-encore');
+import Encore from '@symfony/webpack-encore';
 
 // Manually configure the runtime environment if not already configured yet by the "encore" command.
 // It's useful when you use tools that rely on webpack.config.js file.
@@ -45,15 +45,17 @@ Encore
     // enables hashed filenames (e.g. app.abc123.css)
     .enableVersioning(Encore.isProduction())
 
-    // configure Babel
-    // .configureBabel((config) => {
-    //     config.plugins.push('@babel/a-babel-plugin');
+    // Configure JS and CSS minimizers
+    // .configureJsMinimizerPlugin((options, MinimizerPlugin) => {
+    //     options.minify = MinimizerPlugin.esbuildMinify
+    // })
+    // .configureCssMinimizerPlugin((options, MinimizerPlugin) => {
+    //     options.minify = MinimizerPlugin.lightningCssMinify;
     // })
 
-    // enables and configure @babel/preset-env polyfills
-    .configureBabelPresetEnv((config) => {
-        config.useBuiltIns = 'usage';
-        config.corejs = '3.38';
+    // configure Babel
+    .configureBabel((config) => {
+        config.plugins.push(['polyfill-corejs3', { method: 'usage-global', version: '3.49' }]);
     })
 
     // enables Sass/SCSS support
@@ -73,4 +75,4 @@ Encore
     //.autoProvidejQuery()
 ;
 
-module.exports = Encore.getWebpackConfig();
+export default await Encore.getWebpackConfig();

@Kocal
Kocal marked this pull request as draft June 22, 2026 12:54
auto-merge was automatically disabled June 22, 2026 12:54

Pull request was converted to draft

@Kocal
Kocal force-pushed the webpack-encore-7.0 branch from 4786b9f to 8ca5758 Compare June 22, 2026 12:57
@Kocal
Kocal marked this pull request as ready for review June 22, 2026 12:57
@symfony-recipes-bot
symfony-recipes-bot enabled auto-merge (squash) June 22, 2026 12:58
@Kocal Kocal changed the title [WebpackEncore] Add recipe for 7.0 [WebpackEncore][StimulusBundle] Add recipe for WebpackEncore 7.0 Jun 22, 2026
@Kocal

Kocal commented Jun 22, 2026

Copy link
Copy Markdown
Member Author

I updated the PR to add a fix for StimulusBundle recipe.

Checks are failing, I didn't investigate yet why they fail:

Error: Version "2.13" of "symfony/stimulus-bundle" does not exist on Packagist
Error: Version "2.20" of "symfony/stimulus-bundle" does not exist on Packagist
Error: Version "2.24" of "symfony/stimulus-bundle" does not exist on Packagist
Error: Version "2.25" of "symfony/stimulus-bundle" does not exist on Packagist
Error: Version "2.8" of "symfony/stimulus-bundle" does not exist on Packagist
Error: Version "2.9" of "symfony/stimulus-bundle" does not exist on Packagist
Error: Process completed with exit code 1.

auto-merge was automatically disabled June 24, 2026 08:11

Head branch was pushed to by a user without write access

@Kocal
Kocal force-pushed the webpack-encore-7.0 branch from 8ca5758 to d2494b0 Compare June 24, 2026 08:11
@symfony-recipes-bot
symfony-recipes-bot enabled auto-merge (squash) June 24, 2026 08:13
@Kocal

Kocal commented Jun 24, 2026

Copy link
Copy Markdown
Member Author

The checks fail because symfony/stimulus-bundle 2.8 does not exist on packagist, but its fake recipe was added in #1203. When this check fails, then all other checks for the current package fail too. I opened symfony-tools/recipes-checker#21 to fix this behaviour.

Unfortunately, until fake 2.8 recipe exists, the CI will always fails when touching StimulusBundle recipes. Should we add an exception somewhere, or force-merge?

@fabpot
fabpot disabled auto-merge June 25, 2026 09:52
@fabpot
fabpot merged commit 8b4def2 into symfony:main Jun 25, 2026
1 of 2 checks passed
@Kocal
Kocal deleted the webpack-encore-7.0 branch June 25, 2026 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants