Skip to content

Commit 1e7bad7

Browse files
authored
Merge pull request #180 from maciekgrzybek/master
docs: Add documentation about rollup integration
2 parents 8ccacfd + fec8dbc commit 1e7bad7

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ The following command adds the packages to the project as a development-time dep
2020
- [`awesome-typescript-loader`](#awesome-typescript-loader)
2121
- [`ts-loader`](#ts-loader)
2222
- [Forked process configuration](#Forked-process-configuration)
23+
- [Integration with `Rollup`](#Integration-with-Rollup)
2324
- [TypeScript compiler (CLI)](#TypeScript-compiler-CLI)
2425
- [`ttypescript` compiler](#ttypescript-compiler)
2526
- [API](#API)
@@ -142,6 +143,38 @@ options: {
142143
}
143144
```
144145

146+
# Integration with `Rollup`
147+
148+
This section describes how to integrate the plugin into the build/bundling process driven by [**Rollup**](https://rollupjs.org/guide/en/) and its TypeScript loader - [**rollup-plugin-typescript2**](https://github.com/Igorbek/typescript-plugin-styled-components).
149+
150+
In the `rollup.config.js` file in the section where **rollup-plugin-typescript2** is configured as a loader:
151+
152+
```js
153+
// 1. import default from the plugin module
154+
const createStyledComponentsTransformer = require('typescript-plugin-styled-components').default;
155+
156+
// 2. create a transformer;
157+
// the factory additionally accepts an options object which described below
158+
const styledComponentsTransformer = createStyledComponentsTransformer();
159+
160+
// 3. add getCustomTransformer method to the loader config
161+
var config = {
162+
...
163+
plugins: [
164+
rollupTypescript({
165+
...
166+
transformers: [
167+
() => ({
168+
before: [styledComponentsTransformer],
169+
}),
170+
],
171+
}),
172+
...
173+
],
174+
...
175+
};
176+
```
177+
145178
# TypeScript compiler (CLI)
146179

147180
TypeScript command line compiler tool (`tcs`) does not support using of pluggable modules and transformers.

0 commit comments

Comments
 (0)