2
2
single: Assetic; UglifyJs
3
3
4
4
How to Minify JavaScripts with UglifyJs
5
- =============================================================
5
+ =======================================
6
6
7
7
`UglifyJs `_ is a javascript parser/compressor/beautifier toolkit. It can be used
8
8
to combine and minify javascript assets so they need less HTTP requests and makes
9
9
the website load faster.
10
10
11
11
Install UglifyJs
12
- -------------------------------
12
+ ----------------
13
13
14
- UglifyJs is build as an node.js npm module and can be installed using npm. First, you
15
- need to `install node.js `_. Afterwards you can install UglifyJs using npm:
14
+ UglifyJs is build as an node.js npm module and can be installed using npm. First,
15
+ you need to `install node.js `_. Afterwards you can install UglifyJs using npm:
16
16
17
17
.. code-block :: bash
18
18
@@ -25,13 +25,13 @@ need to `install node.js`_. Afterwards you can install UglifyJs using npm:
25
25
26
26
.. code-block :: bash
27
27
28
- $ npm install uglifyjs /path/to/symfony/app
28
+ $ npm install uglifyjs /path/to/symfony/app/Resources
29
29
30
- It is recommended that you install uglifyjs in your app folder and add the `` node_modules ``
31
- folder to version control.
30
+ It is recommended that you install UglifyJs in your `` app/Resources `` folder
31
+ and add the `` node_modules `` folder to version control.
32
32
33
33
Configure the UglifyJs Filter
34
- -------------------------
34
+ -----------------------------
35
35
36
36
Now we need to configure symfony2 to use the UglifyJs Filter when processing your
37
37
stylesheets:
@@ -68,18 +68,18 @@ stylesheets:
68
68
69
69
.. note ::
70
70
71
- The path where uglifyjs is installed may vary depending on your system.
72
- To find out where npm stores the bin folder, you can use the following
71
+ The path where UglifyJs is installed may vary depending on your system.
72
+ To find out where npm stores the `` bin `` folder, you can use the following
73
73
command:
74
74
75
75
.. code-block :: bash
76
76
77
77
$ npm bin -g
78
78
79
79
It should output a folder on your system, inside which you should find
80
- the uglifyjs executable.
80
+ the UglifyJs executable.
81
81
82
- If you installed uglifyjs locally, you can find the bin folder inside
82
+ If you installed UglifyJs locally, you can find the bin folder inside
83
83
the ``node_modules `` folder. It's called ``.bin `` in this case.
84
84
85
85
You now have access to the ``uglifyjs `` Filter in your application.
@@ -149,7 +149,7 @@ apply this filter when debug mode is off.
149
149
Instead of adding the filter to the asset tags, you can also globally
150
150
enable it by adding the apply-to attribute to the filter configuration, for
151
151
example in the ``uglifyjs `` filter ``apply_to: "\.js$" ``. To only have the filter
152
- applied in production, add this to the config_prod file rather than the
152
+ applied in production, add this to the `` config_prod `` file rather than the
153
153
common config file. For details on applying filters by file extension,
154
154
see :ref: `cookbook-assetic-apply-to `.
155
155
0 commit comments