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

webpack-config-css

v0.2.0

Published

A curated CSS loader config for [Webpack] with [CSS Modules], [PostCSS], and [JS styles].

Downloads

7

Readme

#webpack-config-css

A curated CSS loader config for Webpack with CSS Modules, PostCSS, and JS styles.

build status coverage license version downloads

Usage

Install:

yarn add webpack-config-css

Add to your webpack.config.babel.js:

import css from `webpack-config-css`;

css({/* options */})({
  /* existing webpack configuration */
})

Options

|Name|Default|Description| |:---|:------|:----------| |extract|NODE_ENV === production|Enable/Disable Extract Text Plugin| |modules|true|Enable/Disable CSS Modules| |minimize|NODE_ENV === production|Enable/Disable minification| |jsStyles|true|Enable/Disable support for JS styles| |postcss|true|Enable/Disable PostCSS|

Any additional properties of the options object are forwarded to CSS Loader.

Features

webpack-config-css comes with optimal default settings and requires zero additional config out of the box. However all of the included features are fully full configurable through the options argument.

CSS Modules

Locally scoped CSS is enable by default using CSS Modules. Set modules: false in the options to disable this and restore traditional global CSS selectors.

PostCSS

PostCSS (with autoprefixer and postcss-nesting) is enabled by default. Set postcss: false in the options to disable it.

To use a custom PostCSS config, pass a config object as postcss in the options or include a postcss.config.js (or equivalent) in your project root or in config/postcss/.

Static CSS Output

Extract Text Plugin is enabled by default when NODE_ENV is production. It can be disabled by setting extract: false in the options.

To change the extracted file name or to further configure the plugin, pass a plugin constructor object as extract in the options.

JS Styles

Support for styles written in JS is enabled by default using css-js-loader. CSS styles can be loaded from css.js files alongside regular .css files.

A .js.css file:

export const className = {
  color: 'red',
  fontSize: 24,
};

Yields:

.className {
  color: red;
  font-size: 24px;
};

To support JS styles written in ES6, babel-loader must be configured to load the .css.js files before webpack-config-css in your webpack config:

import flow from 'lodash/fp/flow'
import {loader} from 'webpack-partial';
import css from `webpack-config-css`;

export default flow(
  loader({
    test: /\.js$/,
    exclude: /node_modules/,
    loader: require.resolve('babel-loader'),
  }),
  css(),
)({
  /* existing webpack configuration */
})

To disable JS styles, pass jsStyles: false in the options.