From 4e4b10ffbd85ee22d47a2be05f19983076edc2b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Tue, 7 Jan 2020 19:16:39 +0100 Subject: [PATCH] Updated recipes of webpack-encore. --- config/packages/prod/webpack_encore.yaml | 4 ++++ config/packages/test/webpack_encore.yaml | 2 ++ config/packages/webpack_encore.yaml | 25 ++++++++++++++++++++++-- package.json | 4 +++- symfony.lock | 8 +++++--- webpack.config.js | 11 +++++++++++ 6 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 config/packages/prod/webpack_encore.yaml create mode 100644 config/packages/test/webpack_encore.yaml diff --git a/config/packages/prod/webpack_encore.yaml b/config/packages/prod/webpack_encore.yaml new file mode 100644 index 00000000..d0b3ba81 --- /dev/null +++ b/config/packages/prod/webpack_encore.yaml @@ -0,0 +1,4 @@ +#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 new file mode 100644 index 00000000..02a76515 --- /dev/null +++ b/config/packages/test/webpack_encore.yaml @@ -0,0 +1,2 @@ +#webpack_encore: +# strict_mode: false diff --git a/config/packages/webpack_encore.yaml b/config/packages/webpack_encore.yaml index c1c19d37..9191f4f4 100644 --- a/config/packages/webpack_encore.yaml +++ b/config/packages/webpack_encore.yaml @@ -1,4 +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() and need the crossorigin attribute (default: false, or use 'anonymous' or 'use-credentials') + # crossorigin: 'anonymous' + + # preload all rendered script and link tags automatically via the http2 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 diff --git a/package.json b/package.json index 6ac99b78..da979c33 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,9 @@ "bootstrap": "^4.4.1", "jquery": "^3.3.1", "popper.js": "^1.14.7", - "webpack-notifier": "1.8.0" + "core-js": "^3.0.0", + "regenerator-runtime": "^0.13.2", + "webpack-notifier": "^1.6.0" }, "license": "UNLICENSED", "private": true, diff --git a/symfony.lock b/symfony.lock index 499f39a3..3b1adca7 100644 --- a/symfony.lock +++ b/symfony.lock @@ -773,17 +773,19 @@ ] }, "symfony/webpack-encore-bundle": { - "version": "1.0", + "version": "1.6", "recipe": { "repo": "github.com/symfony/recipes", "branch": "master", - "version": "1.0", - "ref": "5880e1fef9f9eb6a523e698a63f8feabcc8b0834" + "version": "1.6", + "ref": "69e1d805ad95964088bd510c05995e87dc391564" }, "files": [ "./assets/css/app.css", "./assets/js/app.js", "./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 66ae51c2..12be3a7d 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -22,6 +22,12 @@ var Encore = require('@symfony/webpack-encore'); const CopyPlugin = require('copy-webpack-plugin'); +// 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. +if (!Encore.isRuntimeEnvironmentConfigured()) { + Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev'); +} + Encore // directory where compiled assets will be stored .setOutputPath('public/build/') @@ -66,6 +72,11 @@ Encore // enables hashed filenames (e.g. app.abc123.css) .enableVersioning(Encore.isProduction()) + // enables @babel/preset-env polyfills + .configureBabelPresetEnv((config) => { + config.useBuiltIns = 'usage'; + config.corejs = 3; + }) // enables Sass/SCSS support //.enableSassLoader()