@@ -4,8 +4,8 @@ Encore: Setting up your Project
44After :doc: `installing Encore </frontend/encore/installation >`, your app already has one
55CSS and one JS file, organized into an ``assets/ `` directory:
66
7- * ``assets/js/ app.js ``
8- * ``assets/css /app.css ``
7+ * ``assets/app.js ``
8+ * ``assets/styles /app.css ``
99
1010With Encore, think of your ``app.js `` file like a standalone JavaScript
1111application: it will *require * all of the dependencies it needs (e.g. jQuery or React),
@@ -14,7 +14,7 @@ application: it will *require* all of the dependencies it needs (e.g. jQuery or
1414
1515.. code-block :: javascript
1616
17- // assets/js/ app.js
17+ // assets/app.js
1818 // ...
1919
2020 import ' ../css/app.css' ;
@@ -43,14 +43,14 @@ of your project. It already holds the basic config you need:
4343 // public path used by the web server to access the output path
4444 .setPublicPath (' /build' )
4545
46- .addEntry (' app' , ' ./assets/js/ app.js' )
46+ .addEntry (' app' , ' ./assets/app.js' )
4747
4848 // ...
4949 ;
5050
5151 // ...
5252
53- The *key * part is ``addEntry() ``: this tells Encore to load the ``assets/js/ app.js ``
53+ The *key * part is ``addEntry() ``: this tells Encore to load the ``assets/app.js ``
5454file and follow *all * of the ``require() `` statements. It will then package everything
5555together and - thanks to the first ``app `` argument - output final ``app.js `` and
5656``app.css `` files into the ``public/build `` directory.
@@ -115,7 +115,7 @@ can do most of the work for you:
115115.. _encore-entrypointsjson-simple-description :
116116
117117That's it! When you refresh your page, all of the JavaScript from
118- ``assets/js/ app.js `` - as well as any other JavaScript files it included - will
118+ ``assets/app.js `` - as well as any other JavaScript files it included - will
119119be executed. All the CSS files that were required will also be displayed.
120120
121121The ``encore_entry_link_tags() `` and ``encore_entry_script_tags() `` functions
@@ -143,7 +143,7 @@ files. First, create a file that exports a function:
143143
144144.. code-block :: javascript
145145
146- // assets/js/ greet.js
146+ // assets/greet.js
147147 module .exports = function (name ) {
148148 return ` Yo yo ${ name} - welcome to Encore!` ;
149149 };
@@ -158,7 +158,7 @@ Great! Use ``require()`` to import ``jquery`` and ``greet.js``:
158158
159159.. code-block :: diff
160160
161- // assets/js/ app.js
161+ // assets/app.js
162162 // ...
163163
164164 + // loads the jquery package from node_modules
@@ -187,7 +187,7 @@ To export values using the alternate syntax, use ``export``:
187187
188188.. code-block :: diff
189189
190- // assets/js/ greet.js
190+ // assets/greet.js
191191 - module.exports = function(name) {
192192 + export default function(name) {
193193 return `Yo yo ${name} - welcome to Encore!`;
@@ -197,7 +197,7 @@ To import values, use ``import``:
197197
198198.. code-block :: diff
199199
200- // assets/js/ app.js
200+ // assets/app.js
201201 - require('../css/app.css');
202202 + import '../css/app.css';
203203
@@ -219,12 +219,12 @@ etc.). To handle this, create a new "entry" JavaScript file for each page:
219219
220220.. code-block :: javascript
221221
222- // assets/js/ checkout.js
222+ // assets/checkout.js
223223 // custom code for your checkout page
224224
225225 .. code-block :: javascript
226226
227- // assets/js/ account.js
227+ // assets/account.js
228228 // custom code for your account page
229229
230230 Next, use ``addEntry() `` to tell Webpack to read these two new files when it builds:
@@ -234,9 +234,9 @@ Next, use ``addEntry()`` to tell Webpack to read these two new files when it bui
234234 // webpack.config.js
235235 Encore
236236 // ...
237- .addEntry('app', './assets/js/ app.js')
238- + .addEntry('checkout', './assets/js/ checkout.js')
239- + .addEntry('account', './assets/js/ account.js')
237+ .addEntry('app', './assets/app.js')
238+ + .addEntry('checkout', './assets/checkout.js')
239+ + .addEntry('account', './assets/account.js')
240240 // ...
241241
242242 And because you just changed the ``webpack.config.js `` file, make sure to stop
@@ -285,7 +285,7 @@ file to ``app.scss`` and update the ``import`` statement:
285285
286286.. code-block :: diff
287287
288- // assets/js/ app.js
288+ // assets/app.js
289289 - import '../css/app.css';
290290 + import '../css/app.scss';
291291
@@ -336,7 +336,7 @@ If you want to only compile a CSS file, that's possible via ``addStyleEntry()``:
336336 Encore
337337 // ...
338338
339- .addStyleEntry (' some_page' , ' ./assets/css /some_page.css' )
339+ .addStyleEntry (' some_page' , ' ./assets/styles /some_page.css' )
340340 ;
341341
342342 This will output a new ``some_page.css ``.
0 commit comments