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
Copy file name to clipboardExpand all lines: README.md
+29-1Lines changed: 29 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,7 +45,11 @@ yarn add linaria
45
45
46
46
## Setup
47
47
48
-
Linaria requires webpack to build your CSS. To set up the build, add the webpack loader to your `webpack.config.js` after `babel-loader` (if you use it):
48
+
Linaria is compatible with webpack and Rollup.
49
+
50
+
### Webpack
51
+
52
+
To set up the build, add the webpack loader to your `webpack.config.js` after `babel-loader` (if you use it):
49
53
50
54
```js
51
55
module: {
@@ -85,6 +89,29 @@ module: {
85
89
86
90
You also need `css-loader` and `mini-css-extract-plugin` in your pipeline. The usage is shown above.
87
91
92
+
### Rollup
93
+
94
+
To use linaria with Rollup you need to add it to your `rollup.config.js`, together with a plugin which handles CSS files, such as `rollup-plugin-css-only`.
95
+
96
+
```js
97
+
importlinariafrom'linaria/rollup';
98
+
importcssfrom'rollup-plugin-css-only';
99
+
100
+
exportdefault {
101
+
/* rest of your config */
102
+
plugins: [
103
+
/* rest of your plugins */
104
+
linaria({
105
+
sourceMap:process.env.NODE_ENV!=='production'
106
+
}),
107
+
css({
108
+
output:'styles.css'
109
+
})
110
+
]
111
+
};
112
+
```
113
+
114
+
88
115
Now, the CSS you write with Linaria will be extracted at build time to the `styles.css` file. Linaria automatically vendor prefixes and strips whitespace from the CSS.
89
116
90
117
Linaria integrates with your CSS pipeline, so you can always perform additional operations on the CSS, for example, using [postcss](https://postcss.org/) plugins such as [clean-css](https://github.com/jakubpawlowicz/clean-css) to further minify your CSS.
@@ -171,6 +198,7 @@ Dynamic styles will be applied using CSS custom properties (aka CSS variables) a
Copy file name to clipboardExpand all lines: docs/BABEL_PRESET.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# `linaria/babel` preset
2
2
3
-
The preset pre-processes and evaluates the CSS. The webpack loader uses this preset under the hood. You also might want to use this preset if you import the components outside webpack, such as on your server or in unit tests.
3
+
The preset pre-processes and evaluates the CSS. The webpack loader and Rollup plugin use this preset under the hood. You also might want to use this preset if you import the components outside webpack or Rollup, such as on your server or in unit tests.
4
4
5
5
To use this preset, add `linaria/babel` to your Babel configuration at the end of the presets list:
Copy file name to clipboardExpand all lines: docs/BUNDLERS_INTEGRATION.md
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -72,3 +72,25 @@ module.exports = {
72
72
```
73
73
74
74
This will extract the CSS from all files into a single `styles.css`. Then you need to include this file in your HTML file.
75
+
76
+
## Rollup
77
+
78
+
To use linaria with Rollup you need to add it to your `rollup.config.js`, together with a plugin which handles CSS files, such as `rollup-plugin-css-only`.
Copy file name to clipboardExpand all lines: docs/HOW_IT_WORKS.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
Linaria consists of 2 parts:
4
4
5
5
1. Babel plugin
6
-
2. Webpack loader
6
+
2. Webpack loader or Rollup plugin
7
7
8
8
## Babel plugin
9
9
@@ -161,3 +161,7 @@ But keep in mind that if you're doing SSR for your app, this won't work with SSR
161
161
## Webpack loader
162
162
163
163
The webpack loader uses the Babel plugin internally and writes the CSS text to a CSS file, which can be picked up by `css-loader` to generate the final CSS. It's also responsible for generating the sourcemap from the metadata from the Babel plugin.
164
+
165
+
## Rollup plugin
166
+
167
+
The Rollup plugin also uses the Babel plugin, and adds the CSS text to Rollup, to be picked up by a CSS plugin, which can generate the final CSS. It also generates a sourcemap.
0 commit comments