Skip to content

docs: Add documentation about rollup integration #180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The following command adds the packages to the project as a development-time dep
- [`awesome-typescript-loader`](#awesome-typescript-loader)
- [`ts-loader`](#ts-loader)
- [Forked process configuration](#Forked-process-configuration)
- [Integration with `Rollup`](#Integration-with-Rollup)
- [TypeScript compiler (CLI)](#TypeScript-compiler-CLI)
- [`ttypescript` compiler](#ttypescript-compiler)
- [API](#API)
Expand Down Expand Up @@ -142,6 +143,38 @@ options: {
}
```

# Integration with `Rollup`

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).

In the `rollup.config.js` file in the section where **rollup-plugin-typescript2** is configured as a loader:

```js
// 1. import default from the plugin module
const createStyledComponentsTransformer = require('typescript-plugin-styled-components').default;

// 2. create a transformer;
// the factory additionally accepts an options object which described below
const styledComponentsTransformer = createStyledComponentsTransformer();

// 3. add getCustomTransformer method to the loader config
var config = {
...
plugins: [
rollupTypescript({
...
transformers: [
() => ({
before: [styledComponentsTransformer],
}),
],
}),
...
],
...
};
```

# TypeScript compiler (CLI)

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