From 7f1ee500a00c78c6840031fb1cf53023345c9f1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 6 Sep 2023 12:54:47 +0200 Subject: [PATCH] Upgrade recipes: symfony/webpack-encore-bundle --- assets/bootstrap.js | 2 +- config/packages/assets.yaml | 3 --- config/packages/prod/webpack_encore.yaml | 4 ---- config/packages/test/webpack_encore.yaml | 2 -- config/packages/webpack_encore.yaml | 22 +++++++++++++++------- symfony.lock | 11 ++++------- webpack.config.js | 15 +++++++++++++++ 7 files changed, 35 insertions(+), 24 deletions(-) delete mode 100644 config/packages/assets.yaml delete mode 100644 config/packages/prod/webpack_encore.yaml delete mode 100644 config/packages/test/webpack_encore.yaml diff --git a/assets/bootstrap.js b/assets/bootstrap.js index 58308a6..4ab2df6 100644 --- a/assets/bootstrap.js +++ b/assets/bootstrap.js @@ -4,7 +4,7 @@ import { startStimulusApp } from '@symfony/stimulus-bridge'; export const app = startStimulusApp(require.context( '@symfony/stimulus-bridge/lazy-controller-loader!./controllers', true, - /\.(j|t)sx?$/ + /\.[jt]sx?$/ )); // register any custom, 3rd party controllers here diff --git a/config/packages/assets.yaml b/config/packages/assets.yaml deleted file mode 100644 index 051d36d..0000000 --- a/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/config/packages/prod/webpack_encore.yaml b/config/packages/prod/webpack_encore.yaml deleted file mode 100644 index d0b3ba8..0000000 --- a/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/config/packages/test/webpack_encore.yaml b/config/packages/test/webpack_encore.yaml deleted file mode 100644 index 9ad9673..0000000 --- a/config/packages/test/webpack_encore.yaml +++ /dev/null @@ -1,2 +0,0 @@ -webpack_encore: - strict_mode: false diff --git a/config/packages/webpack_encore.yaml b/config/packages/webpack_encore.yaml index 7095312..4f1a501 100644 --- a/config/packages/webpack_encore.yaml +++ b/config/packages/webpack_encore.yaml @@ -1,16 +1,18 @@ ---- webpack_encore: # 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 # 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,11 +25,17 @@ webpack_encore: # If you have multiple builds: # builds: - # pass "frontend" as the 3rg arg to the Twig functions + # pass the build name as the 3rd argument 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 +#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.lock b/symfony.lock index b0709eb..70647cc 100644 --- a/symfony.lock +++ b/symfony.lock @@ -785,12 +785,12 @@ ] }, "symfony/webpack-encore-bundle": { - "version": "1.9", + "version": "1.17", "recipe": { "repo": "github.com/symfony/recipes", - "branch": "master", - "version": "1.9", - "ref": "9399a0bfc6ee7a0c019f952bca46d6a6045dd451" + "branch": "main", + "version": "1.10", + "ref": "eff2e505d4557c967b6710fe06bd947ba555cae5" }, "files": [ "assets/app.js", @@ -798,9 +798,6 @@ "assets/controllers.json", "assets/controllers/hello_controller.js", "assets/styles/app.css", - "config/packages/assets.yaml", - "config/packages/prod/webpack_encore.yaml", - "config/packages/test/webpack_encore.yaml", "config/packages/webpack_encore.yaml", "package.json", "webpack.config.js" diff --git a/webpack.config.js b/webpack.config.js index 9429cf1..9ab0dda 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -109,15 +109,30 @@ module.exports = (async () => { .autoProvidejQuery() .enableSourceMaps(!Encore.isProduction()) .cleanupOutputBeforeBuild() + //.enableBuildNotifications() .enableVersioning() .enableSingleRuntimeChunk() .splitEntryChunks() + // added when upgrading to symfony 5.4 + // enables and configure @babel/preset-env polyfills + //.configureBabelPresetEnv((config) => { + // config.useBuiltIns = 'usage'; + // config.corejs = '3.23'; + //}) //.addLoader({ test: /\.pdf$/, loader: 'file-loader', options: { name: '[name]_[hash].[ext]', outputPath: 'pdf/' } }) ; // populate config with chill entries let chillEntries = []; await populateConfig(Encore, chillEntries); + // configure Babel + // .configureBabel((config) => { + // config.plugins.push('@babel/a-babel-plugin'); + // }) + + + // enables Sass/SCSS support + //.enableSassLoader() // add swagger UI if (!Encore.isProduction()) {