Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A few tiny encore tweaks#8680

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
weaverryan wants to merge2 commits intosymfony:3.3fromweaverryan:encore-tweaks2
Closed
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletionsfrontend.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,6 +25,8 @@ to solve the most common Webpack use cases.
Encore is made by `Symfony`_ and works *beautifully* in Symfony applications.
But it can easily be used in any application... in any language!

.. _encore-toc:

Encore Documentation
--------------------

Expand Down
29 changes: 19 additions & 10 deletionsfrontend/encore/simple-example.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,8 +7,8 @@ an ``assets/`` directory:
* ``assets/js/app.js``
* ``assets/css/app.scss``

Let's consider that the project follows the recommended practiceofimporting
theCSSfiles for their associated JavaScript files:
With Encore, you should think of CSS as a *dependency*ofyour JavaScript. This means,
you will *require* whateverCSSyou need from inside #"bb2e5cdaa64a9b599b1dff90c476a4bfeaa110271b0e92ad356caaeb8f8c0cce">
.. code-block:: javascript

Expand DownExpand Up@@ -38,9 +38,6 @@ Inside, use Encore to help generate your Webpack configuration.
// the public path used by the web server to access the previous directory
.setPublicPath('/build')

// empty the outputPath dir before each build
.cleanupOutputBeforeBuild()

// will create web/build/app.js and web/build/app.css
.addEntry('app', './assets/js/app.js')

Expand All@@ -52,6 +49,12 @@ Inside, use Encore to help generate your Webpack configuration.

.enableSourceMaps(!Encore.isProduction())

// empty the outputPath dir before each build
.cleanupOutputBeforeBuild()

// show OS notifications when builds finish/fail
.enableBuildNotifications()

// create hashed filenames (e.g. app.abc123.css)
// .enableVersioning()
;
Expand DownExpand Up@@ -146,15 +149,16 @@ Great! Use ``require()`` to import ``jquery`` and ``greet.js``:

That's it! When you build your assets, jQuery and ``greet.js`` will automatically
be added to the output file (``app.js``). For common libraries like jQuery, you
may want also to :doc:`create a shared entry </frontend/encore/shared-entry>` for better performance.
may want to :doc:`create a shared entry </frontend/encore/shared-entry>` for better
performance.

Multiple JavaScript Entries
---------------------------

The previous example is the best way to deal with SPA (Single Page Applications)
and very simple applications. However, as yourapplication grows, you'll need to
define more entries with the JavaScript and CSS code of some specific sections
(homepage, blog, store, etc.)
and very simple applications. However, as yourapp grows, you may want to have
page-specific JavaScript or CSS (e.g. homepage, blog, store, etc.). To handle this,
add a new "entry" for each page that needs custom JavaScript or CSS:

.. code-block:: javascript

Expand All@@ -166,5 +170,10 @@ define more entries with the JavaScript and CSS code of some specific sections
;

If those entries include CSS/Sass files (e.g. ``homepage.js`` requires
``assets/css/homepage.scss``), two files will be generated for each of them
``assets/css/homepage.scss``), two files will be generated for each:
(e.g. ``build/homepage.js`` and ``build/homepage.css``).

Keep Going!
-----------

Go back to the :ref:`Encore Top List <encore-toc>` to learn more and add new features.

[8]ページ先頭

©2009-2025 Movatter.jp