What is this
A tool that converts a stylus into scss, or less, or other precompiled CSS.
stylus-converter config
converter options
Attribute | Description | Type | Accepted Values | Default |
---|---|---|---|---|
quote |
The quote type to use when converting strings | string | ' / " |
' |
conver |
Conversion type, such as conversion to scss syntax | string | scss | scss |
autoprefixer |
Whether or not to automatically add a prefix, stylus will automatically add prefixes when converting stylus grammars. @keyframes |
boolean | true / false | true |
indentVueStyleBlock |
Indent the entire style block of a vue file with a certain amount of spaces. | number | number | 0 |
cli options
Attribute | Shorthand | Description | Accepted Values | Default |
---|---|---|---|---|
--quote |
-q |
The quote type to use when converting strings | single / dobule | single |
--input |
-i |
Enter a name, which can be a path to a file or a folder | - | - |
--output |
-o |
Output name, can be a path to a file or a folder | - | - |
--conver |
-c |
Conversion type, such as conversion to scss syntax | scss | scss |
--directory |
-d |
Whether the input and output paths are directories | yes / no | no |
--autoprefixer |
-p |
Whether to add a prefix | yes / no | yes |
--indentVueStyleBlock |
-v |
Indent the entire style block of a vue file with a certain amount of spaces. | number | 0 |
How to handle single line comments
1 First fork project and then clone project to localgit clone git@githubcom:<your github>/stylus-convertergit 2 Enter the project directorycd stylus-converter 3 Installation project dependsnpm install 4 Go to line 581 of the `node_modules/stylus/lib/lexer.js` file 5 Modify the code below// before modificationif '/' == thisstr0 && '/' == thisstr1 var end = thisstr; if -1 == end end = thisstrlength; this; return this; // After modificationif '/' == thisstr0 && '/' == thisstr1 var end = thisstr; const str = thisstr if -1 == end end = thisstrlength; this; return 'comment' str suppress true
Use examples
// download stylus-converternpm install -g stylus-converter // Run the cli conversion filestylus-conver -i teststyl -o testscss // Run the cli conversion directory// cd your projectmv src src-tempstylus-conver -d yes -i src-temp -o src
Conversion file comparison
Stylus source code before conversion
args...) args @media screen and max-width: 500px) and min-width: 100px), max-width: 500px) and min-height: 200px) .foo color: #100 .foo for i in 1..4 @media min-width: 2 * i + 7) px)
Converted SCSS source code
.foo
If you do not want to add the default prefix for your converted @keyframes, please set
options.autoprefixer = false
.vue
file before conversion
The click me
.vue
file
Converted click me
Build a development environment
1. First fork project and then clone project to localgit clone git@github.com:<your github>/stylus-converter.git 2. Enter the project directorycd stylus-converter 3. Installation project dependsnpm install 4. Package compilation source filenpm run build 5. Local debugging clinpm link