Skip to content

Commit 02a0a45

Browse files
committed
minor #13139 Update installation.rst (abdounikarim)
This PR was submitted for the 5.0 branch but it was squashed and merged into the 4.4 branch instead (closes #13139). Discussion ---------- Update installation.rst Hello, I just updated the code using the last known configuration in Symfony Recipes for Webpack Encore Bundle 😉 Commits ------- c37b446 Update installation.rst
2 parents 381217b + c37b446 commit 02a0a45

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

frontend/encore/installation.rst

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ is the main config file for both Webpack and Webpack Encore:
5555
.. code-block:: javascript
5656
5757
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+
}
5865
5966
Encore
6067
// directory where compiled assets will be stored
@@ -76,24 +83,49 @@ is the main config file for both Webpack and Webpack Encore:
7683
.addEntry('app', './assets/js/app.js')
7784
//.addEntry('page1', './assets/js/page1.js')
7885
//.addEntry('page2', './assets/js/page2.js')
86+
87+
// When enabled, Webpack "splits" your files into smaller pieces for greater optimization.
88+
.splitEntryChunks()
7989
8090
// will require an extra script tag for runtime.js
8191
// but, you probably want this, unless you're building a single-page app
8292
.enableSingleRuntimeChunk()
8393
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+
*/
84101
.cleanupOutputBeforeBuild()
102+
.enableBuildNotifications()
85103
.enableSourceMaps(!Encore.isProduction())
86104
// enables hashed filenames (e.g. app.abc123.css)
87105
.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()
88115
89116
// uncomment if you use TypeScript
90117
//.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())
94122
95123
// uncomment if you're having problems with a jQuery plugin
96124
//.autoProvidejQuery()
125+
126+
// uncomment if you use API Platform Admin (composer require api-admin)
127+
//.enableReactPreset()
128+
//.addEntry('admin', './assets/js/admin.js')
97129
;
98130
99131
module.exports = Encore.getWebpackConfig();
@@ -107,7 +139,7 @@ import some CSS:
107139
108140
require('../css/app.css');
109141
110-
console.log('Hello Webpack Encore');
142+
console.log('Hello Webpack Encore! Edit me in assets/js/app.js');
111143
112144
And the new ``assets/css/app.css`` file:
113145

0 commit comments

Comments
 (0)