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

css-entry-webpack-plugin

v1.0.0-beta.4

Published

A Webpack plugin that allows CSS files as the entry.

Downloads

1,616

Readme

Build Status License

A Webpack plugin that simplifies creation of CSS-only bundles.

Installation

NPM Version Dependency Status

Install the plugin using npm:

$ npm install css-entry-webpack-plugin --save-dev

npm

Basic Usage

The plugin will identify the entries that contain only CSS resources and will generate CSS bundles for them.

webpack.config.js

const CssEntryPlugin = require("css-entry-webpack-plugin");

module.exports = {
  entry: {
    "styles": ["src/style1.css", "src/style2.css"],
    "main": "src/index.js"
  },
  output: {
    path: "dist",
    filename: "[name].bundle.js"
  },
  module: {
    rules: [
      // This is required
      {
        test: /\.css$/,
        use: "css-loader"
      }
    ]
  },
  plugins: [
    new CssEntryPlugin({
      output: {
        filename: "[name].bundle.css"
      }
    })
  ]
};

will output two files

main.bundle.js and styles.bundle.css

API

new CssEntryPlugin(options: String | Object)

options

Type: String | Function | Object Optional

Specifies the options for the CssEntryPlugin.

The shorthand version allows you to specify the output.filename directly as a String or a Function, this will be equivalent to passing an object with output.filename. See output.filename for details on the possible values.

new CssEntryPlugin(/* option: String | Function */)
// is equivalent to
new CssEntryPlugin({
  output: {
    filename: /* option */
  }
})

When specified as an Object, the following options are available:

output

Type: Object Optional

Specifies a set of options instructing the plugin on how and where to output your CSS bundles. It works in a similar fashion to Webpack's output option.

new CssEntryPlugin({
  output: { /* output options */ }
})
output.filename

Type: String | Function Default: [name].css Optional

This option determines the name of each CSS output bundle. The bundle is written to the directory specified by the Webpack output.path option. It works in a similar fashion to Webpack's output.filename option and ExtractTextPlugin's filename option.

For a single entry point, this can be a static name.

filename: "bundle.css"

However, when creating multiple bundles via more than one entry point, you should use a template string with one of the following substitutions to give each bundle a unique name.

Using the entry name:

filename: "[name].bundle.css"

Using the internal chunk id:

filename: "[id].bundle.css"

The following substitutions are available in template strings:

|Substitution|Description| |:----------:|:----------| |[name]|The module name or name of the chunk| |[id]|The number of the chunk or module identifier| |[contenthash]|The hash of the content of the extracted file|

Any combination of these substitutions is allowed (eg. "[name].[id].css").

The option can also be specified as a Function which should return the filename as a string without substitutions.

filename: function (getPath /* (template: string) => string */) {
  return "prefix-" + getPath("[name].[id].css");
}

The Function has the signature (getPath: ((template: string) => string)) => string where getPath is a function passed as the first argument, that can be used to perform the substitutions on a given template string to retrieve the original path.

Note this option is called filename but you are still allowed to use or return something like "css/[name]/bundle.css" to create a folder structure.

Note this option only affects CSS output files for entries matched by this plugin (CSS entries).

entries

Type: String | String[] | RegExp | Function Optional and mutually exclusive with ignoreEntries

Specifies the entry or entries to consider as possible CSS entries. Other entries will be ignored.

ignoreEntries

Type: String | String[] | RegExp | Function Optional and mutually exclusive with entries

Specifies the entry or entries to ignore. Other entries will be considered as possible CSS entries.

extensions

Type: String | String[] Default: [".css", ".scss", ".less", ".styl"] Optional and mutually exclusive with test

Specifies which file extensions are valid for files/resources inside considered CSS entries.

test

Type: RegExp | Function Optional and mutually exclusive with extensions

Specifies which files/resources are valid for considered CSS entries.

disable

Type: Boolean Default: false Optional

Disables the plugin.