@@ -55,6 +55,13 @@ is the main config file for both Webpack and Webpack Encore:
55
55
.. code-block :: javascript
56
56
57
57
var Encore = require (' @symfony/webpack-encore' );
58
+
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
+
62
+ if (! Encore .isRuntimeEnvironmentConfigured ()) {
63
+ Encore .configureRuntimeEnvironment (process .env .NODE_ENV || ' dev' );
64
+ }
58
65
59
66
Encore
60
67
// directory where compiled assets will be stored
@@ -76,24 +83,49 @@ is the main config file for both Webpack and Webpack Encore:
76
83
.addEntry (' app' , ' ./assets/js/app.js' )
77
84
// .addEntry('page1', './assets/js/page1.js')
78
85
// .addEntry('page2', './assets/js/page2.js')
86
+
87
+ // When enabled, Webpack "splits" your files into smaller pieces for greater optimization.
88
+ .splitEntryChunks ()
79
89
80
90
// will require an extra script tag for runtime.js
81
91
// but, you probably want this, unless you're building a single-page app
82
92
.enableSingleRuntimeChunk ()
83
93
94
+ /*
95
+ * FEATURE CONFIG
96
+ *
97
+ * Enable & configure other features below. For a full
98
+ * list of features, see:
99
+ * https://symfony.com/doc/current/frontend.html#adding-more-features
100
+ */
84
101
.cleanupOutputBeforeBuild ()
102
+ .enableBuildNotifications ()
85
103
.enableSourceMaps (! Encore .isProduction ())
86
104
// enables hashed filenames (e.g. app.abc123.css)
87
105
.enableVersioning (Encore .isProduction ())
106
+
107
+ // enables @babel/preset-env polyfills
108
+ .configureBabelPresetEnv ((config ) => {
109
+ config .useBuiltIns = ' usage' ;
110
+ config .corejs = 3 ;
111
+ })
112
+
113
+ // enables Sass/SCSS support
114
+ // .enableSassLoader()
88
115
89
116
// uncomment if you use TypeScript
90
117
// .enableTypeScriptLoader()
91
-
92
- // uncomment if you use Sass/SCSS files
93
- // .enableSassLoader()
118
+
119
+ // uncomment to get integrity="..." attributes on your script & link tags
120
+ // requires WebpackEncoreBundle 1.4 or higher
121
+ // .enableIntegrityHashes(Encore.isProduction())
94
122
95
123
// uncomment if you're having problems with a jQuery plugin
96
124
// .autoProvidejQuery()
125
+
126
+ // uncomment if you use API Platform Admin (composer require api-admin)
127
+ // .enableReactPreset()
128
+ // .addEntry('admin', './assets/js/admin.js')
97
129
;
98
130
99
131
module .exports = Encore .getWebpackConfig ();
@@ -107,7 +139,7 @@ import some CSS:
107
139
108
140
require (' ../css/app.css' );
109
141
110
- console .log (' Hello Webpack Encore' );
142
+ console .log (' Hello Webpack Encore! Edit me in assets/js/app.js ' );
111
143
112
144
And the new ``assets/css/app.css `` file:
113
145
0 commit comments