@@ -8,7 +8,7 @@ Compiles css files to importable TypeScript files.
88npm install css-to-ts -g
99```
1010
11- Global installation is not necessary. You can install this package with
11+ Global installation is not necessary. You can install this package with:
1212
1313``` sh
1414npm install css-to-ts
@@ -38,6 +38,7 @@ css-to-ts -h
3838| -v, --version | boolean | ` false ` | Show current version. |
3939| --rootDir | string | ` ./ ` | Specifies the root directory of input files. |
4040| --outDir | string | ` ./ ` | Redirect output structure to the directory. |
41+ | --outExt | string | ` ts ` | Specifies extension of output TypeScript file. |
4142| --pattern | string | ` **/*.css ` | Files glob pattern. |
4243| -w, --watch | boolean | ` false ` | Watch for changes of input files. |
4344| --prefix | string | | Prefix added to output file name. |
@@ -48,6 +49,7 @@ css-to-ts -h
4849| --cwd | string | ` process.cwd() ` | Specifies current working directory. |
4950| --exclude | array | ` ["**/node_modules/**"] ` | Specifies an array of globs to exclude. |
5051| --varName | string | | Specifies name of variable to be exported in TypeScript file. |
52+ | --varType | string | ` const ` | Specifies type of variable to be exported in TypeScript file. |
5153
5254## Example
5355
@@ -68,7 +70,7 @@ Generated `./dist/orange.ts`:
6870
6971``` ts
7072// File generated with css-to-ts
71- export var Orange = ` .orange {
73+ export const Orange = ` .orange {
7274 color: orange;
7375 border: 1px solid yellow;
7476} ` ;
@@ -77,7 +79,7 @@ export var Orange = `.orange {
7779
7880## API
7981
80- ### ` ConvertCssToTs(stringifiedCss: string, variableName: string, headerComment?: string): string `
82+ ### ` ConvertCssToTs(stringifiedCss: string, variableName: string, headerComment?: string, varType: VarType = VarType.Const ): string `
8183
8284Takes stringified css and outputs TypeScript code with exported string containing content of your css file.
8385
@@ -92,8 +94,17 @@ import { ConvertCssToTs } from "css-to-ts";
9294| ` stringifiedCss ` | string | * | Stringified css to be exported in TypeScript file. |
9395| ` variableName ` | string | * | Name of variable to be exported in TypeScript file. |
9496| ` headerComment ` | string | | Comment placed in the top of exported TypeScript file. |
97+ | ` varType ` | string | | Type of variable to be exported in TypeScript file. |
9598
96- ### ` new CssToTsConverter(tsDir, tsFileName, cssDir, cssFileName, varName, header, removeSource) `
99+ ``` ts
100+ export enum VarType {
101+ Var = " var" ,
102+ Let = " let" ,
103+ Const = " const"
104+ }
105+ ```
106+
107+ ### ` new CssToTsConverter(outputDir, outputFileName, cssDir, cssFileName, varName, header, removeSource, varType) `
97108
98109Compiles css files to importable TypeScript files.
99110
@@ -103,8 +114,8 @@ Usage:
103114import { CssToTsConverter } from " css-to-ts" ;
104115
105116const converter = new CssToTsConverter (
106- tsDir ,
107- tsFileName ,
117+ outputDir ,
118+ outputFileName ,
108119 cssDir ,
109120 cssFileName ,
110121 varName ,
@@ -121,13 +132,14 @@ try {
121132
122133| Constructor argument | Type | Required | Description |
123134| -----------------------| -----------| -----------| ---------------------------------------------------------------|
124- | ` tsDir ` | string | * | Directory of TypeScript file. |
125- | ` tsFileName ` | string | * | File name of TypeScript file. |
135+ | ` outputDir ` | string | * | Directory of output file. |
136+ | ` outputFileName ` | string | * | Name of output file. |
126137| ` cssDir ` | string | * | Directory of css file. |
127138| ` cssFileName ` | string | * | File name of css file. |
128139| ` varName ` | string | * | Name of variable to be exported in TypeScript file. |
129140| ` header ` | string | | Comment placed in the top of exported TypeScript file. |
130141| ` removeSource ` | boolean | | Should css file be deleted after TypeScript file emitted. |
142+ | ` varType ` | VarType | | Type of variable to be exported in TypeScript file. |
131143
132144## License
133145
0 commit comments