npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

typescript-sass

v0.0.0

Published

parse sass files for typescript components

Downloads

6

Readme

Typescript Sass

What is this?

This is an experiment that came about from learning a bit of Angular2 and wanting to use sass in component styles. The idea behind this module is that it watches your project for changes in sass files, but instead of making on big sass file it compiles those files into typescript files that can be imported into other typescript files.

If your loader supports it you can technically import raw text files and use those in say, an Angular2 component, but the typescript compiler is going to yell at you since a raw css text file isn't a typescript module. Still not sure what I mean?

Take the following example Angular2 component:

import {Component} from 'angular2/core';
import {DevicesService} from './devices.service';
import mainStyles from "./main.styles";

@Component({
    selector: 'device-list',
    template: `
      <h1>List of devices</h1>
      <ul>
        <li *ngFor="#device of devices">{{device.name}}</li>
      </ul>
    `,
    styles: [mainStyles]
})

export class DeviceListComponent { 
  public devices
  
  constructor(
    private _service: DevicesService
  ){}
  
  ngOnInit() {
    this._service.getDevices().then((devices)=>{
      this.devices = devices
    })
  }
}

mainStyles is a sass file in the devices component directory.

This module makes the attempt to take that sass file and generate a module that will work in this situation and satisfy the typescript compiler.

Original main.styles.sass file:

ul
  list-style: none
li
  display: inline
  a 
    color: blue

and the generated main.styles.ts file:

export default `
ul {
  list-style: none; }

li {
  display: inline; }
  li a {
    color: blue; }

`

Sass imports are also supported currently. Import paths are derived from the parent directory of the compiled file and the sassDir from the config file.

Usage

I've been using this with the concurrently module in my project

package.js

"scripts": {
  "tsc": "tsc",
  "tsc:w": "tsc -w",
  "lite": "lite-server",
  "tsSass": "ts-sass",
  "start": "concurrent \"npm run tsc:w\" \"npm run lite\" \"npm run tsSass\""
},

For Basic configuration you can include a tsSassConfig.json file in your project root:

{
  "sassDir": "app",
  "sassSubDir": "sass"
}

sassDir - Indicates that main directory to watch for sass files. I point this towards my angular app directory where my components live. This should not include node_modules it's just using fs.watch so there isn't a great way to exclude node_modules.

sassSubDir - Indicates if you want your sass files in a separate directory within you component directories. I've been experimenting with a /sass directory to reduce clutter. If this option isn't set then the compiled .ts files will be placed in the same directory as the original .sass files.

Wat, no tests?!

Yea, its just an experiment at this point and it's small enough where I'm not too worried yet. If there is interest I might make this a bit better, like supporting other stuff then just sass (less/haml/jade/etc)