4
4
How to Use Assetic for Asset Management
5
5
=======================================
6
6
7
- Assetic combines two major ideas: :ref: `assets <cookbook- assetic-assets >` and
8
- :ref: `filters <cookbook- assetic-filters >`. The assets are files such as CSS,
7
+ Assetic combines two major ideas: :ref: `assets <assetic-assets >` and
8
+ :ref: `filters <assetic-filters >`. The assets are files such as CSS,
9
9
JavaScript and image files. The filters are things that can be applied to
10
10
these files before they are served to the browser. This allows a separation
11
11
between the asset files stored in the application and the files actually presented
@@ -34,7 +34,7 @@ load them from anywhere) before serving them. This means you can:
34
34
35
35
* Run image optimizations on your images
36
36
37
- .. _ cookbook-assetic -assets :
37
+ .. _ assetic -assets :
38
38
39
39
Assets
40
40
------
@@ -43,12 +43,12 @@ Using Assetic provides many advantages over directly serving the files.
43
43
The files do not need to be stored where they are served from and can be
44
44
drawn from various sources such as from within a bundle.
45
45
46
- You can use Assetic to process :ref: `CSS stylesheets <cookbook- assetic-including-css >`,
47
- :ref: `JavaScript files <cookbook- assetic-including-javascript >` and
48
- :ref: `images <cookbook- assetic-including-image >`. The philosophy
46
+ You can use Assetic to process :ref: `CSS stylesheets <assetic-including-css >`,
47
+ :ref: `JavaScript files <assetic-including-javascript >` and
48
+ :ref: `images <assetic-including-image >`. The philosophy
49
49
behind adding either is basically the same, but with a slightly different syntax.
50
50
51
- .. _ cookbook-assetic -including-javascript :
51
+ .. _ assetic -including-javascript :
52
52
53
53
Including JavaScript Files
54
54
~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -89,7 +89,7 @@ To include JavaScript files, use the ``javascripts`` tag in any template:
89
89
90
90
.. tip ::
91
91
92
- You can also include CSS stylesheets: see :ref: `cookbook- assetic-including-css `.
92
+ You can also include CSS stylesheets: see :ref: `assetic-including-css `.
93
93
94
94
In this example, all files in the ``Resources/public/js/ `` directory of the
95
95
AppBundle will be loaded and served from a different location. The actual
@@ -101,9 +101,9 @@ rendered tag might simply look like:
101
101
102
102
This is a key point: once you let Assetic handle your assets, the files are
103
103
served from a different location. This *will * cause problems with CSS files
104
- that reference images by their relative path. See :ref: `cookbook- assetic-cssrewrite `.
104
+ that reference images by their relative path. See :ref: `assetic-cssrewrite `.
105
105
106
- .. _ cookbook-assetic -including-css :
106
+ .. _ assetic -including-css :
107
107
108
108
Including CSS Stylesheets
109
109
~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -146,7 +146,7 @@ except with the ``stylesheets`` tag:
146
146
147
147
But because Assetic changes the paths to your assets, this *will * break any
148
148
background images (or other paths) that uses relative paths, unless you use
149
- the :ref: `cssrewrite <cookbook- assetic-cssrewrite >` filter.
149
+ the :ref: `cssrewrite <assetic-cssrewrite >` filter.
150
150
151
151
.. note ::
152
152
@@ -157,7 +157,7 @@ the :ref:`cssrewrite <cookbook-assetic-cssrewrite>` filter.
157
157
that there is a known issue that causes the ``cssrewrite `` filter to fail
158
158
when using the ``@AppBundle `` syntax for CSS stylesheets.
159
159
160
- .. _ cookbook-assetic -including-image :
160
+ .. _ assetic -including-image :
161
161
162
162
Including Images
163
163
~~~~~~~~~~~~~~~~
@@ -189,7 +189,7 @@ You can also use Assetic for image optimization. More information in
189
189
`LiipImagineBundle `_ community bundle, which allows to compress and
190
190
manipulate images (rotate, resize, watermark, etc.) before serving them.
191
191
192
- .. _ cookbook-assetic -cssrewrite :
192
+ .. _ assetic -cssrewrite :
193
193
194
194
Fixing CSS Paths with the ``cssrewrite `` Filter
195
195
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -250,7 +250,7 @@ the JavaScript files.
250
250
If you're new to Assetic and try to use your application in the ``prod ``
251
251
environment (by using the ``app.php `` controller), you'll likely see
252
252
that all of your CSS and JS breaks. Don't worry! This is on purpose.
253
- For details on using Assetic in the ``prod `` environment, see :ref: `cookbook- assetic-dumping `.
253
+ For details on using Assetic in the ``prod `` environment, see :ref: `assetic-dumping `.
254
254
255
255
And combining files doesn't only apply to *your * files. You can also use Assetic to
256
256
combine third party assets, such as jQuery, with your own into a single file:
@@ -354,7 +354,7 @@ with the ``@named_asset`` notation:
354
354
<script src="<?php echo $view->escape($url) ?>"></script>
355
355
<?php endforeach ?>
356
356
357
- .. _ cookbook-assetic -filters :
357
+ .. _ assetic -filters :
358
358
359
359
Filters
360
360
-------
@@ -474,7 +474,7 @@ done from the template and is relative to the public document root:
474
474
via configuration on each deployment. For more information, see the
475
475
:ref: `reference-framework-assets-version ` configuration option.
476
476
477
- .. _ cookbook-assetic -dumping :
477
+ .. _ assetic -dumping :
478
478
479
479
Dumping Asset Files
480
480
-------------------
@@ -508,7 +508,7 @@ by Symfony (as the asset files are in the ``dev`` environment). This is on
508
508
purpose - letting Symfony generate these files dynamically in a production
509
509
environment is just too slow.
510
510
511
- .. _ cookbook-assetic -dump-prod :
511
+ .. _ assetic -dump-prod :
512
512
513
513
Instead, each time you use your application in the ``prod `` environment (and therefore,
514
514
each time you deploy), you should run the following command:
0 commit comments