@@ -56,6 +56,12 @@ is the main config file for both Webpack and Webpack Encore:
56
56
57
57
var Encore = require (' @symfony/webpack-encore' );
58
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
+ if (! Encore .isRuntimeEnvironmentConfigured ()) {
62
+ Encore .configureRuntimeEnvironment (process .env .NODE_ENV || ' dev' );
63
+ }
64
+
59
65
Encore
60
66
// directory where compiled assets will be stored
61
67
.setOutputPath (' public/build/' )
@@ -77,23 +83,48 @@ is the main config file for both Webpack and Webpack Encore:
77
83
// .addEntry('page1', './assets/js/page1.js')
78
84
// .addEntry('page2', './assets/js/page2.js')
79
85
86
+ // When enabled, Webpack "splits" your files into smaller pieces for greater optimization.
87
+ .splitEntryChunks ()
88
+
80
89
// will require an extra script tag for runtime.js
81
90
// but, you probably want this, unless you're building a single-page app
82
91
.enableSingleRuntimeChunk ()
83
92
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
+ */
84
100
.cleanupOutputBeforeBuild ()
101
+ .enableBuildNotifications ()
85
102
.enableSourceMaps (! Encore .isProduction ())
86
103
// enables hashed filenames (e.g. app.abc123.css)
87
104
.enableVersioning (Encore .isProduction ())
88
105
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
+
89
115
// uncomment if you use TypeScript
90
116
// .enableTypeScriptLoader()
91
117
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())
94
121
95
122
// uncomment if you're having problems with a jQuery plugin
96
123
// .autoProvidejQuery()
124
+
125
+ // uncomment if you use API Platform Admin (composer require api-admin)
126
+ // .enableReactPreset()
127
+ // .addEntry('admin', './assets/js/admin.js')
97
128
;
98
129
99
130
module .exports = Encore .getWebpackConfig ();
@@ -107,7 +138,7 @@ import some CSS:
107
138
108
139
require (' ../css/app.css' );
109
140
110
- console .log (' Hello Webpack Encore' );
141
+ console .log (' Hello Webpack Encore! Edit me in assets/js/app.js ' );
111
142
112
143
And the new ``assets/css/app.css `` file:
113
144
0 commit comments