Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

css-to-ts

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-to-ts

css-to-ts takes css file and outputs TypeScript file with an exported string containing content of your css file.

  • 0.1.0-beta.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
818
increased by27.61%
Maintainers
1
Weekly downloads
 
Created
Source

css-to-ts

Compiles css files to importable TypeScript files.

Instalation

$ npm install css-to-ts

Features

  • Takes css file and outputs TypeScript file with exported string containing content of your css file.
  • CLI tooling for watching and files compilation.
  • Works with glob patterns.

Command line

Usage

    $ css-to-ts -h

Arguments

ArgumentTypeDefaultDescription
-h, --helpbooleanfalseShow help.
-v, --versionbooleanfalseShow current version.
--rootDir [*]stringSpecifies the root directory of input files.
-o, --outDir [*]stringRedirect output structure to the directory.
--pattern [*]stringFiles glob pattern.
-w, --watchbooleanfalseWatch for changes of input files.
--prefixstringPrefix added to ouput file name.
--suffixstringSuffix added to output file name.
--delimitterstringSpecifies delimitter for prefix and suffix. Required if one of these are set.
--removeSourcebooleanfalseRemove all source files specified by glob pattern.
--headerstringSpecifies header comment in generated TS file.
--cwdstringprocess.cwd()Specifies current working directory.

[*] - argument required.

Example

$  node ./dist/cli.js --rootDir "./src" --outDir "./dist" --pattern "*.css" --header "File generated with css-to-ts"

Input file ./src/orange.css

.orange {
    color: orange;
    border: 1px solid yellow;
}

Generated ./dist/orange.ts

// File generated with css-to-ts
export var Orange = `.orange {
    color: orange;
    border: 1px solid yellow;
}`;

API

ConvertCssToTs(stringifiedCss: string, variableName: string, headerComment?: string): string

Takes stringified css and outputs TypeScript code with exported string containing content of your css file.

Usage:

import { ConvertCssToTs } from "css-to-ts";
ArgumentTypeRequiredDescription
stringifiedCssstring*Stringified css to be exported in TypeScript file.
variableNamestring*Name of variable to be exported in TypeScript file.
headerCommentstringComment placed in the top of exported TypeScript file.

CssToTsConverter

Compiles css file to importable TypeScript file.

Usage:

import { CssToTsConverter } from "css-to-ts";

const converter = new CssToTsConverter(
    tsDir,
    tsFileName,
    cssDir,
    cssFileName,
    varName,
    header,
    removeSource
);

try {
    await converter.Convert();
} catch(error) {
    console.error(error);
}
Constructor argumentTypeDefaultDescription
tsDirstringundefinedDirectory of TypeScript file.
tsFileNamestringundefinedFile name of TypeScript file.
cssDirstringundefinedDirectory of css file.
cssFileNamestringundefinedFile name of css file.
varNamestringundefinedName of variable to be exported in TypeScript file.
headerstringundefinedComment placed in the top of exported TypeScript file.
removeSourcebooleanfalseShould css file be deleted after TS file emmitted.

License

Released under the MIT license.

Keywords

FAQs

Package last updated on 11 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc