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

@revenuegrid/style2dts

v1.0.0

Published

Webpack plugin for automatic d.ts files generation for style source files.

Downloads

9

Readme

Welcome to Style2DTS webpack plugin!

This is a webpack plugin that generates typescript definition (.d.ts) files on fly, allowing to import less/css files into typescript code and always have up to date .d.ts content while editing style source files. Implmentation was initially inspired by two existing NPM packages

  • https://github.com/dropbox/typed-css-modules-webpack-plugin
  • https://github.com/awexfwex/typed-less-modules

Thanks guys! However we had to add some improvements which are necessary to track less files, which support @import statement.

Features

  • Generates .d.ts files in build and watch webpack modes.
  • Tracks dependencies so if "common.less" is modified, plugin generates .d.ts files for everything that imports "common.less". Actually this is the main purpose of the plugin.
  • Tracks file deletions - if you delete less file - plugin will delete .d.ts file

Usage

const { Style2DTS } = require('@revenuegrid/style2dts');

module.exports = {
  entry: './src/index.ts',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'bundle.js',
  },
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        loader: 'ts-loader',
      },
      {
        test: /\.less/,
        use: [
          'style-loader',
          // Use CSS Modules
          {
            loader: 'css-loader',
            options: {
              modules: true,
            },
          },
          'less-loader'
        ],
      },
    ],
  },
  // Generate typing declarations for all CSS files under `src/` directory.
  plugins: [
    new Style2DTS ({
      globPattern: 'src/**/*.less',
    }),
  ],
};

Options

The available options for the plugin are:

globPattern: string

This is the glob pattern used to match Style Modules in the project. The plugin only generates .d.ts for the matching Style files. Currently only Less and CSS files are supported. See node-glob for the pattern syntax.

nameFormat?: "camel" | "kebab" | "param" | "dashes" | "none"

Tells plugin how to generate class names exports. if not specified camel is used.

exportType?: "named" | "default"

Tells plugin how to generate .d.ts file content. if not specified default is used.

  • named - exports several constants per each style entry. Suitable for importing explicit styles. Import example: import { a, b,c } from './style.less;
  • default - exports default object containing all style entries. Suitable for default import. Import example: import Styles from './style.less;

Requirements

  • Webpack version 5.34.0 or higher.