You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/index.rst
+36-16Lines changed: 36 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,8 @@ Sass For Symfony!
4
4
This bundle makes it easy to use Sass with Symfony's AssetMapper Component
5
5
(no Node required!).
6
6
7
-
- Automatically downloads the correct Sass binary
7
+
- Automatically detects the Sass binary installed in the system
8
+
- Automatically downloads the correct Sass binary if it's not detected in the system
8
9
- Adds a ``sass:build`` command to build and watch your Sass changes
9
10
10
11
.. tip::
@@ -25,7 +26,7 @@ Install the bundle:
25
26
Usage
26
27
-----
27
28
28
-
Start by writing your first Sass file ``assets/styles/app.scss``, and let's add some basic style
29
+
Start by writing your first Sass file ``assets/styles/app.scss``, and let's add some basic style:
29
30
30
31
.. code-block:: scss
31
32
@@ -37,7 +38,7 @@ Start by writing your first Sass file ``assets/styles/app.scss``, and let's add
37
38
background: $red;
38
39
}
39
40
40
-
Then point your styles in your template
41
+
Then point your styles in your template:
41
42
42
43
.. code-block:: html+twig
43
44
@@ -79,16 +80,21 @@ to be started whenever you run ``symfony server:start``:
79
80
How Does it Work?
80
81
-----------------
81
82
82
-
The first time you run one of the Sass commands, the bundle will download the correct Sass binary for your system into the ``bin/dart-sass`` directory.
83
+
The first time you run one of the Sass commands, the bundle will automatically try to detect
84
+
the correct Sass binary installed in the system and use it. If the binary is not found,
85
+
the bundle will automatically download the correct one for your system and put it into
86
+
the ``bin/dart-sass`` directory.
83
87
84
-
When you run ``sass:build``, that binary is used to compile Sass files into a ``var/sass/app.built.css`` file. Finally, when the contents of ``assets/styles/app.scss`` are requested, the bundle swaps the contents of that file with the contents of ``var/sass/app.built.css``. Nice!
88
+
When you run ``sass:build``, that binary is used to compile Sass files into a ``var/sass/app.built.css``
89
+
file. Finally, when the contents of ``assets/styles/app.scss`` are requested, the bundle swaps
90
+
the contents of that file with the contents of ``var/sass/app.built.css``. Nice!
85
91
86
92
Excluding Sass Files from AssetMapper
87
93
-------------------------------------
88
94
89
95
Because you have ``.scss`` files in your ``assets/`` directory, when you deploy, these
90
96
source files will be copied into the ``public/assets/`` directory. To prevent that,
91
-
you can exclude them from asset mapper:
97
+
you can exclude them from AssetMapper:
92
98
93
99
.. code-block:: yaml
94
100
# config/packages/asset_mapper.yaml
@@ -106,19 +112,20 @@ you can exclude them from asset mapper:
106
112
this *is* used in AssetMapper and its contents are swapped for the final, built CSS.
107
113
108
114
109
-
How to Get Source Sass Files for 3rd-party Libraries
115
+
How to Get Source Sass Files for 3rd-Party Libraries
The easiest way to get 3rd-party Sass files is via Composer. For example, see
113
-
the section below to know how to get the source Sass files for Bootstrap.
118
+
The easiest way to get 3rd-party Sass files is via `Composer<https://getcomposer.org/>`_. For example, see
119
+
the section below to know how to get the source Sass files for `Bootstrap<https://getbootstrap.com/>`_.
114
120
115
121
But if you're using a library that isn't available via Composer, you’ll need
116
122
to either download it to your app manually or grab it via NPM.
117
123
118
124
Using Bootstrap Sass
119
125
~~~~~~~~~~~~~~~~~~~~
120
126
121
-
`Bootstrap <https://getbootstrap.com/>`_ is available as Sass, allowing you to customize the look and feel of your app. An easy way to get the source Sass files is via a Composer package:
127
+
`Bootstrap <https://getbootstrap.com/>`_ is available as Sass, allowing you to customize
128
+
the look and feel of your app. An easy way to get the source Sass files is via a Composer package:
122
129
123
130
.. code-block:: terminal
124
131
@@ -169,7 +176,8 @@ When you deploy, run ``sass:build`` command before the ``asset-map:compile`` com
169
176
Limitation: ``url()`` Relative Paths
170
177
------------------------------------
171
178
172
-
When using ``url()`` inside a Sass file, currently, the path must be relative to the *root* ``.scss`` file. For example, suppose the root ``.scss`` file is:
179
+
When using ``url()`` inside a Sass file, currently, the path must be relative to the *root* ``.scss`` file.
180
+
For example, suppose the root ``.scss`` file is:
173
181
174
182
.. code-block:: scss
175
183
@@ -189,7 +197,8 @@ Assume there is an ``assets/images/login-bg.png`` file that you want to refer to
189
197
background-image: url('../images/login-bg.png');
190
198
}
191
199
192
-
It should be possible to use ``url()`` with a path relative to the current file. However, that is not currently possible. See `this issue <https://github.com/SymfonyCasts/sass-bundle/issues/2>`_ for more details.
200
+
It should be possible to use ``url()`` with a path relative to the current file. However, that is not
201
+
currently possible. See `this issue <https://github.com/SymfonyCasts/sass-bundle/issues/2>`_ for more details.
193
202
194
203
Configuration
195
204
-------------
@@ -204,13 +213,14 @@ To see the full config from this bundle, run:
204
213
Source Sass file
205
214
~~~~~~~~~~~~~~~~
206
215
207
-
The main option is ``root_sass`` option, which defaults to ``assets/styles/app.scss``. This represents the source Sass file.
216
+
The main option is the ``root_sass`` option, which defaults to ``assets/styles/app.scss``.
217
+
This represents the source Sass file:
208
218
209
219
.. code-block:: yaml
210
220
211
221
# config/packages/symfonycasts_sass.yaml
212
222
symfonycasts_sass:
213
-
root_sass: 'assets/styles/app.scss'
223
+
root_sass: 'assets/styles/app.scss'
214
224
215
225
.. note::
216
226
@@ -241,7 +251,7 @@ You can configure most of the `Dart Sass CLI options <https://sass-lang.com/docu
241
251
# Register additional load paths. Defaults to empty array.
242
252
# load_path: []
243
253
244
-
#Wether to generate source maps. Defaults to true when "kernel.debug" is true.
254
+
#Whether to generate source maps. Defaults to true when "kernel.debug" is true.
245
255
# source_map: true
246
256
247
257
# Embed source file contents in source maps. Defaults to false.
@@ -266,13 +276,23 @@ You can configure most of the `Dart Sass CLI options <https://sass-lang.com/docu
266
276
Using a different binary
267
277
------------------------
268
278
269
-
This bundle already installed for you the right binary. However, if you already have a binary installed on your machine you can instruct the bundle to use that binary, set the ``binary`` option:
279
+
This bundle has already detected or installed for you the right binary. However, if you already have a binary
280
+
installed on your machine and somehow the bundle has not been able to find it automatically - you can instruct
281
+
the bundle to use that binary, set the ``binary`` option:
270
282
271
283
.. code-block:: yaml
272
284
273
285
symfonycasts_sass:
274
286
binary: 'node_modules/.bin/sass'
275
287
288
+
.. tip::
289
+
290
+
If a path in the ``binary`` option is explicitly specified - the bundle will just use it
291
+
which means it will not try to search a binary itself or download it automatically for your system.
292
+
To let the bundle take care of it automatically - do not specify the ``binary`` option.
0 commit comments