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
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!).
6
6
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
10
10
11
11
Installation
12
12
------------
@@ -20,17 +20,19 @@ Install the bundle:
20
20
Usage
21
21
-----
22
22
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.
24
25
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:
@@ -61,6 +62,7 @@ command as a `worker <https://symfony.com/doc/current/setup/symfony_server.html#
61
62
to be started whenever you run ``symfony server:start``:
62
63
63
64
.. code-block:: yaml
65
+
64
66
# .symfony.local.yaml
65
67
workers:
66
68
# ...
@@ -75,37 +77,47 @@ to be started whenever you run ``symfony server:start``:
75
77
How Does it Work?
76
78
-----------------
77
79
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.
79
82
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
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.
92
99
93
100
Using a different binary
94
-
--------------------------
101
+
------------------------
95
102
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:
97
106
98
107
.. code-block:: yaml
99
108
109
+
# config/packages/asset_mapper.yaml
100
110
sensiolabs_typescript:
101
111
binary: 'node_modules/.bin/swc'
102
112
103
113
Configuring the compiler
104
-
--------------------------
114
+
------------------------
105
115
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:
0 commit comments