@@ -7,8 +7,8 @@ an ``assets/`` directory:
77* ``assets/js/app.js ``
88* ``assets/css/app.scss ``
99
10- Let's consider that the project follows the recommended practice of importing
11- the CSS files for their associated JavaScript files :
10+ With Encore, you should think of CSS as a * dependency * of your JavaScript. This means,
11+ you will * require * whatever CSS you need from inside JavaScript:
1212
1313.. code-block :: javascript
1414
@@ -38,9 +38,6 @@ Inside, use Encore to help generate your Webpack configuration.
3838 // the public path used by the web server to access the previous directory
3939 .setPublicPath (' /build' )
4040
41- // empty the outputPath dir before each build
42- .cleanupOutputBeforeBuild ()
43-
4441 // will create web/build/app.js and web/build/app.css
4542 .addEntry (' app' , ' ./assets/js/app.js' )
4643
@@ -52,6 +49,12 @@ Inside, use Encore to help generate your Webpack configuration.
5249
5350 .enableSourceMaps (! Encore .isProduction ())
5451
52+ // empty the outputPath dir before each build
53+ .cleanupOutputBeforeBuild ()
54+
55+ // show OS notifications when builds finish/fail
56+ .enableBuildNotifications ()
57+
5558 // create hashed filenames (e.g. app.abc123.css)
5659 // .enableVersioning()
5760 ;
@@ -146,15 +149,16 @@ Great! Use ``require()`` to import ``jquery`` and ``greet.js``:
146149
147150 That's it! When you build your assets, jQuery and ``greet.js `` will automatically
148151be added to the output file (``app.js ``). For common libraries like jQuery, you
149- may want also to :doc: `create a shared entry </frontend/encore/shared-entry >` for better performance.
152+ may want to :doc: `create a shared entry </frontend/encore/shared-entry >` for better
153+ performance.
150154
151155Multiple JavaScript Entries
152156---------------------------
153157
154158The previous example is the best way to deal with SPA (Single Page Applications)
155- and very simple applications. However, as your application grows, you'll need to
156- define more entries with the JavaScript and CSS code of some specific sections
157- (homepage, blog, store, etc.)
159+ and very simple applications. However, as your app grows, you may want to have
160+ page-specific JavaScript or CSS (e.g. homepage, blog, store, etc.). To handle this,
161+ add a new "entry" for each page that needs custom JavaScript or CSS:
158162
159163.. code-block :: javascript
160164
@@ -166,5 +170,10 @@ define more entries with the JavaScript and CSS code of some specific sections
166170 ;
167171
168172 If those entries include CSS/Sass files (e.g. ``homepage.js `` requires
169- ``assets/css/homepage.scss ``), two files will be generated for each of them
173+ ``assets/css/homepage.scss ``), two files will be generated for each:
170174(e.g. ``build/homepage.js `` and ``build/homepage.css ``).
175+
176+ Keep Going!
177+ -----------
178+
179+ Go back to the :ref: `Encore Top List <encore-toc >` to learn more and add new features.
0 commit comments