@@ -166,9 +166,10 @@ We'll use jQuery to print this message on the page. Install it via:
166
166
Great! Use ``import `` to import ``jquery `` and ``greet.js ``:
167
167
168
168
.. code-block :: diff
169
+ :dedent: 0
169
170
170
- // assets/app.js
171
- // ...
171
+ // assets/app.js
172
+ // ...
172
173
173
174
+ // loads the jquery package from node_modules
174
175
+ import jquery from 'jquery';
@@ -208,14 +209,15 @@ etc.). To handle this, create a new "entry" JavaScript file for each page:
208
209
Next, use ``addEntry() `` to tell Webpack to read these two new files when it builds:
209
210
210
211
.. code-block :: diff
212
+ :dedent: 0
211
213
212
- // webpack.config.js
213
- Encore
214
- // ...
215
- .addEntry('app', './assets/app.js')
214
+ // webpack.config.js
215
+ Encore
216
+ // ...
217
+ .addEntry('app', './assets/app.js')
216
218
+ .addEntry('checkout', './assets/checkout.js')
217
219
+ .addEntry('account', './assets/account.js')
218
- // ...
220
+ // ...
219
221
220
222
And because you just changed the ``webpack.config.js `` file, make sure to stop
221
223
and restart Encore:
@@ -232,9 +234,10 @@ Finally, include the ``script`` and ``link`` tags on the individual pages where
232
234
you need them:
233
235
234
236
.. code-block :: diff
237
+ :dedent: 0
235
238
236
- {# templates/.../checkout.html.twig #}
237
- {% extends 'base.html.twig' %}
239
+ {# templates/.../checkout.html.twig #}
240
+ {% extends 'base.html.twig' %}
238
241
239
242
+ {% block stylesheets %}
240
243
+ {{ parent() }}
@@ -262,21 +265,23 @@ CSS you can also use Sass, LESS or Stylus. To use Sass, rename the ``app.css``
262
265
file to ``app.scss `` and update the ``import `` statement:
263
266
264
267
.. code-block :: diff
268
+ :dedent: 0
265
269
266
- // assets/app.js
270
+ // assets/app.js
267
271
- import './styles/app.css';
268
272
+ import './styles/app.scss';
269
273
270
274
Then, tell Encore to enable the Sass pre-processor:
271
275
272
276
.. code-block :: diff
277
+ :dedent: 0
273
278
274
- // webpack.config.js
275
- Encore
276
- // ...
279
+ // webpack.config.js
280
+ Encore
281
+ // ...
277
282
278
283
+ .enableSassLoader()
279
- ;
284
+ ;
280
285
281
286
Because you just changed your ``webpack.config.js `` file, you'll need to restart
282
287
Encore. When you do, you'll see an error!
0 commit comments