Skip to content

Commit a738698

Browse files
committed
add minimize example, rename url
1 parent 3fe8701 commit a738698

File tree

1 file changed

+77
-4
lines changed

1 file changed

+77
-4
lines changed

README.md

+77-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ ICSS allows to describe imports and exports in CSS. The following syntax is allo
3434
@import url('other-module/style.css');
3535
```
3636

37-
Imports other CSS files.
37+
Imports other CSS files. Imports are hoisted in ICSS.
3838

3939
#### Importing Symbols
4040

@@ -55,6 +55,9 @@ The local alias can be used in the complete file and has the value of the export
5555

5656
The imported module could be another ICSS file or any other module.
5757

58+
The imported identifier must be a valid javascript identifier (dashes are not allowed).
59+
The local alias must be a valid css identifier (dashes are allowed).
60+
5861
#### Exporting Symbols
5962

6063
``` css
@@ -73,6 +76,9 @@ export const otherExportedName = "5px 5px, red";
7376

7477
Note that spacing is not significant.
7578

79+
The exported identifier must be a valid javascript identifier (dashes are not allowed).
80+
`default` should not be used a export name.
81+
7682

7783
<h2 align="center">Examples</h2>
7884

@@ -81,13 +87,13 @@ Note that spacing is not significant.
8187
It's often needed to thread `url()`s in the CSS file as imports to other assets.
8288
You want to add all referenced assets into the dependency graph.
8389

84-
This can be achieved by a postcss plugin: postcss-plugin-url.
90+
This can be achieved by a postcss plugin: postcss-plugin-icss-url.
8591

8692
To enable postcss plugins in your CSS pipeline, chain css-loader with postcss-loader.
8793
Example configuration with style-loader:
8894

8995
``` js
90-
const urlPlugin = require("postcss-plugin-url")
96+
const urlPlugin = require("postcss-plugin-icss-url")
9197

9298
rules: [
9399
{
@@ -118,7 +124,7 @@ rules: [
118124
It's often needed to use a preprocessor for CSS. Example: SASS.
119125

120126
``` js
121-
const urlPlugin = require("postcss-plugin-url")
127+
const urlPlugin = require("postcss-plugin-icss-url")
122128

123129
rules: [
124130
{
@@ -145,6 +151,67 @@ rules: [
145151
]
146152
```
147153

154+
### Minimizing CSS
155+
156+
For production builds it's useful to minimize the CSS. This can be done via postcss plugin:
157+
158+
``` js
159+
const cssnano = require("cssnano")
160+
161+
rules: [
162+
{
163+
test: /\.css$/,
164+
rules: [
165+
{
166+
issuer: { not: /\.css$/ },
167+
use: "style-loader"
168+
},
169+
{
170+
use: [
171+
"css-loader",
172+
{
173+
loader: "postcss-loader",
174+
plugins: [
175+
cssnano({
176+
// options
177+
})
178+
]
179+
}
180+
]
181+
}
182+
]
183+
}
184+
]
185+
```
186+
187+
### Extract
188+
189+
For production builds it's recommended to extract the CSS from your bundle being able to use parallel loading of CSS/JS resources later on. This can be achieved by using the [extract-text-webpack-plugin](https://github.com/webpack-contrib/extract-text-webpack-plugin) to extract the CSS when running in production mode.
190+
191+
<h2 align="center">Options</h2>
192+
193+
|Name|Type|Default|Description|
194+
|:--:|:--:|:-----:|:----------|
195+
|**`sourceMap`**|`{Boolean}`|`false`|Enable/Disable Sourcemaps|
196+
197+
### `sourceMap`
198+
199+
To include source maps set the `sourceMap` option.
200+
201+
I. e. the extract-text-webpack-plugin or the style-loader can handle them.
202+
203+
They are not enabled by default because they expose a runtime overhead and increase in bundle size (JS source maps do not). In addition to that relative paths are buggy and you need to use an absolute public path which include the server URL.
204+
205+
**webpack.config.js**
206+
```js
207+
{
208+
loader: 'css-loader',
209+
options: {
210+
sourceMap: true
211+
}
212+
}
213+
```
214+
148215
<h2 align="center">Maintainers</h2>
149216

150217
<table>
@@ -194,6 +261,12 @@ rules: [
194261
</br>
195262
<a href="https://github.com/joscha">Joscha Feth</a>
196263
</td>
264+
<td align="center">
265+
<img width="150" height="150"
266+
src="https://github.com/sokra.png?v=3&s=150">
267+
</br>
268+
<a href="https://github.com/sokra">Tobias Koppers</a>
269+
</td>
197270
</tr>
198271
<tbody>
199272
</table>

0 commit comments

Comments
 (0)