@@ -47,35 +47,44 @@ Configure TypeScript to allow arbitrary extensions (TS 5+).
4747```
4848
4949Add ` *.d.css.ts ` to your ` .gitignore ` if appropriate.
50+ (See [ #4 ] for more information about alternative output directory.)
5051
5152``` shell
5253echo ' *.d.css.ts' >> .gitignore
5354```
5455
56+ [ #4 ] : https://github.com/connorjs/css-typed/issues/4
57+
5558## Options
5659
5760The following table lists the options ` css-typed ` supports.
58- Prior to the ` 1.0 ` release, these may change often .
61+ Also run ` css-typed -h ` on the command line .
5962
60- | CLI option | Description |
61- | :--------: | :----------- ----------------------------- |
62- | ` --dashes ` | Specifies the convention used for locals . |
63+ | CLI option | Default | Description |
64+ | :------------------ : | :----------: | : ----------------------------- |
65+ | ` --localsConvention ` | ` dashesOnly ` | Style of exported class names . |
6366
64- ### Dashes
67+ ### localsConvention
6568
66- _ Inspired by [ postcss’ localsConvention] ( https://github.com/madyankin/postcss-modules/tree/master #localsconvention ) .
67- Prior to ` v1.0 ` , this option will evolve to more closely match the ` localsConvention ` option. _
69+ Inspired by [ postcss localsConvention] ( https://github.com/madyankin/postcss-modules#localsconvention ) .
70+ Adds ` none ` option value to use the class name as-is.
6871
69- The ` --dashes ` option changes the style of exported classnames , the exports in your TS.
72+ The ` --localsConvention ` option changes the style of exported class names , the exports in your TS (i.e., the JS names) .
7073
71- By default, ` css-typed ` will emit class names as-is if the name represents a valid JS/TS identifier.
72- _ Note: The logic for “valid” only checks hyphens (dashes, ` - ` ) as of ` v0.2.2 ` ._
74+ ` css-typed ` will only camelize dashes in class names by default (the ` dashesOnly ` option value).
75+ It will not preserve the original class name.
76+ For example, ` my-class ` becomes ` myClass ` and you cannot use ` my-class ` in JS/TS code.
7377
74- When passed ` dashes ` , it will transform ` kebab-case ` classes (dashed names) to ` camelCase ` .
75- For example, ` my-class ` becomes ` myClass ` .
78+ Modern bundlers or build system such as Vite and Gatsby support this transformation .
79+ The default matches CSS naming practices ( ` kebab-case ` ) .
7680
77- Use ` --dashes ` when your bundler or build system supports that transformation.
78- For example, Vite and Gatsby support this.
81+ > ** IMPORTANT**
82+ >
83+ > Note that the non-` *Only ` values MAY have TypeScript bugs.
84+ > TypeScript 5.6 may help with the named exports for these.
85+ >
86+ > If you encounter a bug, please file an issue.
87+ > In the mean-time, consider using ` camelCaseOnly ` instead (or ` dashesOnly ` which is the default).
7988
8089## Recipes
8190
@@ -86,8 +95,8 @@ To run it as part of your build, you will likely include it as a run script, may
8695``` json
8796{
8897 "scripts" : {
89- "codegen" : " css-typed ' src/**/*.css' " ,
90- "pretsc" : " css-typed ' src/**/*.css' " ,
98+ "codegen" : " css-typed \" src/**/*.css\" " ,
99+ "pretsc" : " css-typed \" src/**/*.css\" " ,
91100 "tsc" : " tsc"
92101 }
93102}
@@ -101,8 +110,8 @@ Feel free to [nodemon] or similar.
101110``` json
102111{
103112 "scripts" : {
104- "codegen" : " css-typed ' src/**/*.css' " ,
105- "codegen:watch" : " nodemon -x ' npm run codegen' -w src -e css"
113+ "codegen" : " css-typed \" src/**/*.css\" " ,
114+ "codegen:watch" : " nodemon -x \" npm run codegen\" -w src -e css"
106115 }
107116}
108117```
0 commit comments