@@ -168,7 +168,7 @@ Great! Use ``require()`` to import ``jquery`` and ``greet.js``:
168
168
.. code-block :: diff
169
169
170
170
// assets/js/app.js
171
- // ...
171
+ // ...
172
172
173
173
+ // loads the jquery package from node_modules
174
174
+ var $ = require('jquery');
@@ -199,8 +199,8 @@ To export values using the alternate syntax, use ``export``:
199
199
// assets/js/greet.js
200
200
- module.exports = function(name) {
201
201
+ export default function(name) {
202
- return `Yo yo ${name} - welcome to Encore!`;
203
- };
202
+ return `Yo yo ${name} - welcome to Encore!`;
203
+ };
204
204
205
205
To import values, use ``import ``:
206
206
@@ -241,12 +241,12 @@ Next, use ``addEntry()`` to tell Webpack to read these two new files when it bui
241
241
.. code-block :: diff
242
242
243
243
// webpack.config.js
244
- Encore
245
- // ...
246
- .addEntry('app', './assets/js/app.js')
244
+ Encore
245
+ // ...
246
+ .addEntry('app', './assets/js/app.js')
247
247
+ .addEntry('checkout', './assets/js/checkout.js')
248
248
+ .addEntry('account', './assets/js/account.js')
249
- // ...
249
+ // ...
250
250
251
251
And because you just changed the ``webpack.config.js `` file, make sure to stop
252
252
and restart Encore:
@@ -263,9 +263,10 @@ Finally, include the ``script`` and ``link`` tags on the individual pages where
263
263
you need them:
264
264
265
265
.. code-block :: diff
266
+ :dedent: 0
266
267
267
- {# templates/.../checkout.html.twig #}
268
- {% extends 'base.html.twig' %}
268
+ {# templates/.../checkout.html.twig #}
269
+ {% extends 'base.html.twig' %}
269
270
270
271
+ {% block stylesheets %}
271
272
+ {{ parent() }}
@@ -303,11 +304,11 @@ Then, tell Encore to enable the Sass pre-processor:
303
304
.. code-block :: diff
304
305
305
306
// webpack.config.js
306
- Encore
307
- // ...
307
+ Encore
308
+ // ...
308
309
309
310
+ .enableSassLoader()
310
- ;
311
+ ;
311
312
312
313
Because you just changed your ``webpack.config.js `` file, you'll need to restart
313
314
Encore. When you do, you'll see an error!
0 commit comments