@@ -56,6 +56,12 @@ is the main config file for both Webpack and Webpack Encore:
5656
5757 var Encore = require (' @symfony/webpack-encore' );
5858
59+ // Manually configure the runtime environment if not already configured yet by the "encore" command.
60+ // It's useful when you use tools that rely on webpack.config.js file.
61+ if (! Encore .isRuntimeEnvironmentConfigured ()) {
62+ Encore .configureRuntimeEnvironment (process .env .NODE_ENV || ' dev' );
63+ }
64+
5965 Encore
6066 // directory where compiled assets will be stored
6167 .setOutputPath (' public/build/' )
@@ -77,23 +83,48 @@ is the main config file for both Webpack and Webpack Encore:
7783 // .addEntry('page1', './assets/js/page1.js')
7884 // .addEntry('page2', './assets/js/page2.js')
7985
86+ // When enabled, Webpack "splits" your files into smaller pieces for greater optimization.
87+ .splitEntryChunks ()
88+
8089 // will require an extra script tag for runtime.js
8190 // but, you probably want this, unless you're building a single-page app
8291 .enableSingleRuntimeChunk ()
8392
93+ /*
94+ * FEATURE CONFIG
95+ *
96+ * Enable & configure other features below. For a full
97+ * list of features, see:
98+ * https://symfony.com/doc/current/frontend.html#adding-more-features
99+ */
84100 .cleanupOutputBeforeBuild ()
101+ .enableBuildNotifications ()
85102 .enableSourceMaps (! Encore .isProduction ())
86103 // enables hashed filenames (e.g. app.abc123.css)
87104 .enableVersioning (Encore .isProduction ())
88105
106+ // enables @babel/preset-env polyfills
107+ .configureBabelPresetEnv ((config ) => {
108+ config .useBuiltIns = ' usage' ;
109+ config .corejs = 3 ;
110+ })
111+
112+ // enables Sass/SCSS support
113+ // .enableSassLoader()
114+
89115 // uncomment if you use TypeScript
90116 // .enableTypeScriptLoader()
91117
92- // uncomment if you use Sass/SCSS files
93- // .enableSassLoader()
118+ // uncomment to get integrity="..." attributes on your script & link tags
119+ // requires WebpackEncoreBundle 1.4 or higher
120+ // .enableIntegrityHashes(Encore.isProduction())
94121
95122 // uncomment if you're having problems with a jQuery plugin
96123 // .autoProvidejQuery()
124+
125+ // uncomment if you use API Platform Admin (composer require api-admin)
126+ // .enableReactPreset()
127+ // .addEntry('admin', './assets/js/admin.js')
97128 ;
98129
99130 module .exports = Encore .getWebpackConfig ();
@@ -107,7 +138,7 @@ import some CSS:
107138
108139 require (' ../css/app.css' );
109140
110- console .log (' Hello Webpack Encore' );
141+ console .log (' Hello Webpack Encore! Edit me in assets/js/app.js ' );
111142
112143 And the new ``assets/css/app.css `` file:
113144
0 commit comments