Skip to content

Commit a9be207

Browse files
[Doc] Minor fixes (#36)
1 parent 3794523 commit a9be207

File tree

1 file changed

+33
-21
lines changed

1 file changed

+33
-21
lines changed

doc/index.rst

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
TypeScript Bundle For Symfony
2-
=================
2+
=============================
33

4-
This bundle allows you to compile TypeScript and use it with Symfony's AssetMapper Component
5-
(no Node required!).
4+
This bundle allows you to compile TypeScript and use it with Symfony's AssetMapper
5+
Component (no Node.js required!).
66

7-
- Automatically downloads the correct `SWC <https://github.com/swc-project/swc>`_ binary
8-
- Adds a ``typescript:build`` command to compile your typescript files
9-
- Automatically compiles your typescript files when you run ``asset-map:compile`` command
7+
* Automatically downloads the correct `SWC <https://github.com/swc-project/swc>`_ binary
8+
* Adds a ``typescript:build`` command to compile your TypeScript files
9+
* Automatically compiles your TypeScript files when you run ``asset-map:compile`` command
1010

1111
Installation
1212
------------
@@ -20,17 +20,19 @@ Install the bundle:
2020
Usage
2121
-----
2222

23-
Start by setting the ``sensiolabs_typescript.source_dir`` option to the list of location where your typescript files are located.
23+
Start by setting the ``sensiolabs_typescript.source_dir`` option to the list of
24+
locations where your TypeScript files are located.
2425

25-
For instance, if your TypeScript code lives in ``assets/typescript`` directory, with a ``assets/typescript/app.ts`` entrypoint file, you could set the option like this:
26+
For instance, if your TypeScript code lives in ``assets/typescript/`` directory,
27+
with an ``assets/typescript/app.ts`` entrypoint file, set the option like this:
2628

2729
.. code-block:: yaml
2830
2931
# config/packages/asset_mapper.yaml
3032
sensiolabs_typescript:
3133
source_dir: ['%kernel.project_dir%/assets/typescript']
3234
33-
Then point your TypeScript files in your templates
35+
Then load your TypeScript files in your templates:
3436

3537
.. code-block:: html+twig
3638

@@ -40,15 +42,14 @@ Then point your TypeScript files in your templates
4042
<script type="text/javascript" src="{{ asset('typescript/app.ts') }}"></script>
4143
{% endblock %}
4244

43-
44-
Then run the command:
45+
Finally run this command:
4546

4647
.. code-block:: terminal
4748
48-
# To compile only the typescript files
49+
# to compile only the TypeScript files
4950
$ php bin/console typescript:build --watch
5051
51-
# To compile ALL your assets
52+
# to compile ALL your assets
5253
$ php bin/console asset-map:compile
5354
5455
And that's it!
@@ -61,6 +62,7 @@ command as a `worker <https://symfony.com/doc/current/setup/symfony_server.html#
6162
to be started whenever you run ``symfony server:start``:
6263

6364
.. code-block:: yaml
65+
6466
# .symfony.local.yaml
6567
workers:
6668
# ...
@@ -75,37 +77,47 @@ to be started whenever you run ``symfony server:start``:
7577
How Does it Work?
7678
-----------------
7779

78-
The first time you run one of the TypeScript commands, the bundle will download the correct SWC binary for your system into the ``var`` directory.
80+
The first time you run one of the TypeScript commands, the bundle will download
81+
the correct SWC binary for your system into the ``var/`` directory.
7982

80-
When you run ``typescript:build``, that binary is used to compile TypeScript files into a ``var/typescript`` directory. Finally, when the contents of ``assets/typescript/app.ts`` is requested, the bundle swaps the contents of that file with the contents of from ``var/typescript/`` directory.
83+
When you run ``typescript:build``, that binary is used to compile TypeScript files
84+
into a ``var/typescript/`` directory. Finally, when the contents of ``assets/typescript/app.ts``
85+
is requested, the bundle swaps the contents of that file with the contents of
86+
the ``var/typescript/`` directory.
8187

8288
Configuration
83-
--------------
89+
-------------
8490

8591
To see the full config from this bundle, run:
8692

8793
.. code-block:: terminal
8894
8995
$ php bin/console config:dump sensiolabs_typescript
9096
91-
The main option is ``source_dir`` option, which defaults to ``[%kernel.project_dir%/assets]``. This is an array of directories that will be compiled.
97+
The main option is ``source_dir``, which defaults to ``[%kernel.project_dir%/assets]``.
98+
This is an array of the directories that will be compiled.
9299

93100
Using a different binary
94-
--------------------------
101+
------------------------
95102

96-
This bundle already installed for you the right SWC binary. However, if you already have a SWC binary installed on your machine you can instruct the bundle to use that binary, set the ``binary`` option:
103+
This bundle already installed for you the right SWC binary. However, if you already
104+
have a SWC binary installed on your machine you can instruct the bundle to use
105+
that binary with the ``binary`` option:
97106

98107
.. code-block:: yaml
99108
109+
# config/packages/asset_mapper.yaml
100110
sensiolabs_typescript:
101111
binary: 'node_modules/.bin/swc'
102112
103113
Configuring the compiler
104-
--------------------------
114+
------------------------
105115

106-
You can configure the SWC compiler by setting the ``swc_config_file`` option to the the path to your `.swcrc <https://swc.rs/docs/configuration/swcrc>`_ file:
116+
You can configure the SWC compiler by setting the ``swc_config_file`` option to
117+
the the path to your `.swcrc <https://swc.rs/docs/configuration/swcrc>`_ file:
107118

108119
.. code-block:: yaml
109120
121+
# config/packages/asset_mapper.yaml
110122
sensiolabs_typescript:
111123
swc_config_file: '%kernel.project_dir%/.swcrc'

0 commit comments

Comments
 (0)