@@ -54,11 +54,11 @@ const result = transform("App.jsx", sourceCode, {
54
54
55
55
#### Configuration Options
56
56
57
- | Option | Type | Default | Description |
58
- | --------| ------| ---------| -------------|
59
- | ` refreshReg ` | ` string ` | ` "$RefreshReg$" ` | The name of the function to register components for refresh |
60
- | ` refreshSig ` | ` string ` | ` "$RefreshSig$" ` | The name of the function to create signatures for refresh |
61
- | ` emitFullSignatures ` | ` boolean ` | ` false ` | Whether to emit full signatures for better debugging |
57
+ | Option | Type | Default | Description |
58
+ | -------------------- | --------- | ---------------- | ----------------------------------------------------------- |
59
+ | ` refreshReg ` | ` string ` | ` "$RefreshReg$" ` | The name of the function to register components for refresh |
60
+ | ` refreshSig ` | ` string ` | ` "$RefreshSig$" ` | The name of the function to create signatures for refresh |
61
+ | ` emitFullSignatures ` | ` boolean ` | ` false ` | Whether to emit full signatures for better debugging |
62
62
63
63
### Styled Components
64
64
@@ -84,8 +84,9 @@ const result = transform("Component.jsx", sourceCode, {
84
84
#### Example
85
85
86
86
** Input:**
87
+
87
88
``` jsx
88
- import styled from ' styled-components' ;
89
+ import styled from " styled-components" ;
89
90
90
91
const Button = styled .div `
91
92
color: blue;
@@ -94,69 +95,71 @@ const Button = styled.div`
94
95
```
95
96
96
97
** Output (with default options):**
98
+
97
99
``` jsx
98
- import styled from ' styled-components' ;
100
+ import styled from " styled-components" ;
99
101
100
102
const Button = styled .div .withConfig ({
101
103
displayName: " Button" ,
102
- componentId: " sc-1234567-0"
104
+ componentId: " sc-1234567-0" ,
103
105
})([" color:blue;padding:10px;" ]);
104
106
```
105
107
106
108
#### Configuration Options
107
109
108
110
##### Core Options
109
111
110
- | Option | Type | Default | Description |
111
- | --------| ------| ---------| -------------|
112
- | ` displayName ` | ` boolean ` | ` true ` | Enhances the attached CSS class name with component names for easier debugging |
113
- | ` ssr ` | ` boolean ` | ` true ` | Adds unique component IDs to avoid checksum mismatches during server-side rendering |
114
- | ` fileName ` | ` boolean ` | ` true ` | Controls whether the displayName is prefixed with the filename |
112
+ | Option | Type | Default | Description |
113
+ | ------------- | --------- | ------- | ----------------------------------------------------------------------------------- |
114
+ | ` displayName ` | ` boolean ` | ` true ` | Enhances the attached CSS class name with component names for easier debugging |
115
+ | ` ssr ` | ` boolean ` | ` true ` | Adds unique component IDs to avoid checksum mismatches during server-side rendering |
116
+ | ` fileName ` | ` boolean ` | ` true ` | Controls whether the displayName is prefixed with the filename |
115
117
116
118
##### Template Literal Options
117
119
118
- | Option | Type | Default | Description |
119
- | --------| ------| ---------| -------------|
120
- | ` transpileTemplateLiterals ` | ` boolean ` | ` true ` | Converts template literals to a smaller representation for reduced bundle size |
121
- | ` minify ` | ` boolean ` | ` true ` | Minifies CSS content by removing whitespace and comments |
120
+ | Option | Type | Default | Description |
121
+ | --------------------------- | --------- | ------- | ------------------------------------------------------------------------------ |
122
+ | ` transpileTemplateLiterals ` | ` boolean ` | ` true ` | Converts template literals to a smaller representation for reduced bundle size |
123
+ | ` minify ` | ` boolean ` | ` true ` | Minifies CSS content by removing whitespace and comments |
122
124
123
125
##### Advanced Options
124
126
125
- | Option | Type | Default | Description |
126
- | --------| ------| ---------| -------------|
127
- | ` pure ` | ` boolean ` | ` false ` | Adds ` /*#__PURE__*/ ` comments for better tree-shaking |
128
- | ` namespace ` | ` string ` | ` undefined ` | Adds a namespace prefix to component IDs |
127
+ | Option | Type | Default | Description |
128
+ | ---------------------- | ---------- | ----------- | ------------------------------------------------------------- |
129
+ | ` pure ` | ` boolean ` | ` false ` | Adds ` /*#__PURE__*/ ` comments for better tree-shaking |
130
+ | ` namespace ` | ` string ` | ` undefined ` | Adds a namespace prefix to component IDs |
129
131
| ` meaninglessFileNames ` | ` string[] ` | ` ["index"] ` | List of filenames considered meaningless for component naming |
130
132
131
133
##### Not Yet Implemented
132
134
133
- | Option | Type | Default | Description |
134
- | --------| ------| ---------| -------------|
135
- | ` cssProp ` | ` boolean ` | ` true ` | JSX css prop transformation (planned) |
136
- | ` topLevelImportPaths ` | ` string[] ` | ` [] ` | Custom import path handling (planned) |
135
+ | Option | Type | Default | Description |
136
+ | --------------------- | ---------- | ------- | ------------------------------------- |
137
+ | ` cssProp ` | ` boolean ` | ` true ` | JSX css prop transformation (planned) |
138
+ | ` topLevelImportPaths ` | ` string[] ` | ` [] ` | Custom import path handling (planned) |
137
139
138
140
#### Supported Import Patterns
139
141
140
142
The plugin works with various styled-components import patterns:
141
143
142
144
``` javascript
143
145
// Default import
144
- import styled from ' styled-components' ;
146
+ import styled from " styled-components" ;
145
147
146
148
// Namespace import
147
- import * as styled from ' styled-components' ;
149
+ import * as styled from " styled-components" ;
148
150
149
151
// Named imports
150
- import { css , createGlobalStyle , keyframes } from ' styled-components' ;
152
+ import { createGlobalStyle , css , keyframes } from " styled-components" ;
151
153
152
154
// Native and primitives
153
- import styled from ' styled-components/native' ;
154
- import styled from ' styled-components/primitives' ;
155
+ import styled from " styled-components/native" ;
156
+ import styled from " styled-components/primitives" ;
155
157
```
156
158
157
159
#### Features
158
160
159
161
** ✅ Fully Supported:**
162
+
160
163
- Display names for debugging
161
164
- Filename prefixing in display names
162
165
- Server-side rendering support
@@ -166,9 +169,11 @@ import styled from 'styled-components/primitives';
166
169
- Pure annotations for call expressions
167
170
168
171
** ⚠️ Partially Supported:**
172
+
169
173
- Pure annotations (call expressions only, not tagged templates due to bundler limitations)
170
174
171
175
** ❌ Not Yet Implemented:**
176
+
172
177
- JSX css prop transformation
173
178
- Custom import path handling
174
179
0 commit comments