@@ -13,25 +13,58 @@ or webpack](https://lightningcss.dev/docs.html) instead.
1313## Installation
1414
1515python-lightningcss includes wheels which can be installed for most platforms
16- using pip: ` pip install lightningcss ` .
16+ using pip:
17+
18+ $ pip install lightningcss
1719
1820Alternatively, python-lightningcss may be installed directly from source:
19- ` pip install git+https://github.com/pydsigner/python-lightningcss ` . This will
20- require that the Rust toolchain be installed.
21+
22+ $ pip install git+https://github.com/pydsigner/python-lightningcss
23+
24+ This will require that the Rust toolchain be installed.
2125
2226## Usage
2327
2428``` py
2529import lightningcss
2630
2731parser_flags = lightningcss.calc_parser_flags(nesting = True )
32+
2833input_css = """
29- a {
30- padding-left: 0;
31- padding-right: 0;
32- padding-top: 5px;
33- padding-bottom: 5px;
34+ .navbar {
35+ margin: 0;
36+
37+ a {
38+ padding-left: 0;
39+ padding-right: 0;
40+ padding-top: 5px;
41+ padding-bottom: 5px;
42+ }
3443}
3544"""
36- output_css = lightningcss.process_stylesheet(input_css, filename = " abc.css" , browsers_list = [' defaults' ])
45+
46+ output_css = lightningcss.process_stylesheet(
47+ input_css,
48+ filename = " abc.css" ,
49+ parser_flags = parser_flags,
50+ browsers_list = [' defaults' ],
51+ minify = True ,
52+ )
3753```
54+
55+ This package also supports creating a CSS bundle where all ` @import ` rules are
56+ resolved into a single stylesheet:
57+
58+ ``` py
59+ bundled_css = lightningcss.bundle_css(
60+ " main.css" ,
61+ filename = " main.css" ,
62+ browsers_list = [" defaults" ],
63+ minify = False ,
64+ )
65+ ```
66+
67+ All resources referenced via ` @import ` are resolved relative to the main file. The
68+ ` filename ` keyword parameter is only used for displaying error messages from the
69+ parser. When using ` browsers_list ` , lightningcss will try to transpile the code
70+ to be compatible with the specified [ browserslist target] ( https://browsersl.ist/ ) .
0 commit comments