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 🙏

© 2024 – Pkg Stats / Ryan Hefner

roc-plugin-typed-css-modules

v2.0.1

Published

A roc plugin to enable the typed-css-modules, which generates typescript definition files for your css files.

Downloads

25

Readme

roc-plugin-typed-css-modules

A roc plugin to enable the typed-css-modules, which generates typescript definition files for your css files.

How to use?

Install the plugin as a dev dependency in your roc project:

npm install --save-dev roc-plugin-typed-css-modules

The plugin will now automatically scan any css imports you have in your .ts and .tsx files and generate d.ts-files for them. Be aware though that no type definition files are generated until you reference a style in your css file:

import * as React from 'react';
// It's not enough to just import the style...
import * as styles from './style.scss';

export const MyReactComponent = () => (
// ...you need to reference it as well before the plugin will kick in and generate type definitions!
  <div className={styles.main}>
    <p>Hello CSS Modules world!</p>
  </div>
);

Once a reference has been made, the plugin will automatically refresh the type definitions when you add new styles into your CSS-file.

Caveats

Currently, the webpack build with roc isn't automatically rerunning after the type definitions have been generated, which means that the typescript compiler will fail when trying to compile the file that is referencing the CSS file. Right now, the solution is unfortunately to rerun the build (or, in development, restart the dev server). For more on these issues, see this discussion.

Could not find required extension. Needs roc-plugin-typescript@^version

You'll get this warning if the typescript plugin isn't loaded before this plugin is. Per default, roc will look for any roc-plugin-* packages in your package.json and load them in alphabetic order. To get rid of the warning, you'll need to specify the load order explicitly in your package.json file:

    ...
    "devDependencies": {
        ...
        // Alphabetic order
        "roc-plugin-typed-css-modules": "^2.0.0",
        "roc-plugin-typescript": "^2.0.0-alpha",
        ...
    },
    "roc": {
        // Needed to specify load order correctly to fullfill plugin dependencies
        "plugins": [
            ...
            // Reverse order from above
            "roc-plugin-typescript",
            "roc-plugin-typed-css-modules",
            ...
        ]
    }

Documentation


Generated by Roc