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

stylable-webpack-plugin

v1.1.7

Published

Webpack (4.x) plugin for Stylable modules

Readme

Stylable Webpack Plugin

The Stylable Webpack Plugin (for Webpack version 4x) is the main build utility for Stylable. It supports both development and production modes, providing various configurations that can be tweaked according to your specific needs. It enables loading Stylable files (.st.css) from local projects or imported from a 3rd party source (for example, NPM node modules).

Getting started

Install stylable-webpack-plugin as a dev dependency in your local project.

Install using npm:

npm install stylable-webpack-plugin --save-dev

Install using yarn:

yarn add stylable-webpack-plugin --dev

Sample dev config:

// webpack.config.js
module.exports = {
  …
  plugins: [new StylableWebpackPlugin()]
  …
};

Plugin Configuration Options

Some of the default values given to configuration parameters depend on what environment mode is currently active in webpack (development or production). Below you can see the various possible configuration parameters and their default values.

| Option | Type | Development Mode Default | Production Mode Default | Description | |---------|:-----:|:-----------------:|:----------------:|------------| |outputCSS | boolean | false | true | Generate CSS asset files per bundle | |filename | string | - | [name].bundle.css | The name of the CSS bundle file when outputCSS is enabled | |includeCSSInJS | boolean | true | false | Include target CSS in the JavaScript modules (used by runtime renderer) | | createRuntimeChunk | boolean | false | false | Move all Stylable modules into a separate chunk with a runtime renderer | | rootScope | boolean | true | true | Enable automatically scoping the root component (will default to false in the upcoming future)| | bootstrap.autoInit | boolean | true | true | Initialize the rendering of the CSS in the browser | | optimize.removeUnusedComponents | boolean | true | true | Remove selectors that contain namespaces (classes) that are not imported by JavaScript | | optimize.removeComments | boolean | false | true | Remove CSS comments from the target | | optimize.removeStylableDirectives | boolean | true | true | Remove all -st-* from target (currently also removes empty rules which will be a separate option coming soon) | | optimize.classNameOptimizations | boolean | false | true | Shorten all class names and replace them in the JavaScript modules | | optimize.shortNamespaces | boolean | false | true | Shorten all namespaces which affects the resulting data-* selectors and DOM attributes | | optimize.minify | boolean | false | true | Minify each css asset. |

Sample production configuration

new StylableWebpackPlugin({ 
    outputCSS: true, 
    includeCSSInJS: false,
    optimize: {
      removeUnusedComponents: true,
      removeComments: true,
      removeStylableDirectives: true,
      classNameOptimizations: true,
      shortNamespaces: true,
      minify: true
    }
})

Asset handling

CSS assets are handled by a url-loader + file-loader combination.

 module: {
    rules: [
      {
        test: /\.(png|jpg|gif)$/,
        use: [
          {
            loader: "url-loader",
            options: {
              limit: 8192
            }
          }
        ]
      }
    ]
  }

Compatibilities with existing loading mechanisms

If you're using css_loader/extract make sure to exclude .st.css files from the process. You cannot use loaders with Stylable .st.css files

How it works (in case you're wondering)

The plugin transforms all Stylable files into JavaScript modules with CSS rendering capabilities.

Every bundle that contains Stylable modules is injected with a stylable-bootstrap-module as its entrypoint. This module is responsible for:

  • Ensuring that all of the transformed modules are imported in the proper order.
  • Initializing the runtime DOM renderer.

The resulting renderer orders the CSS by the depth of each module, calculated from its dependencies and component dependencies.

Stylable bootstrap module The stylable-bootstrap-module is a generated module injected into the bundle as its entrypoint and ensures all Stylable modules are injected into the runtime renderer.

Runtime DOM renderer The core Stylable runtime renderer in the browser is responsible for rendering stylesheets in the correct order in the DOM.