@aofl/webcomponent-css-loader

3.5.0 • Public • Published

@aofl/webcomponent-css-loader

The @aofl/webcomponent-css-loader is a webpack loader that inlines imported css in your component's bundle and prunes unused css.

Getting started

Run npm i -D @aofl/webcomponent-css-loader

Then add the loader to your webpack config:

module: {
  rules: [
    {
      test: /\.css$/,
      use: [
        {
          loader: '@aofl/webcomponent-css-loader',
          options: {
            cache: true
          }
        }
      ]
    }
  ]
}

In addition to adding the loader to webpack config you must also place a comment block in css files that you want to be picked up by the loader. This allows us to set the pruning behavior per component/css file.

For more information visit Purgecss docs.

/**!
 * @aoflComponent
 * @whitelist ['modal']
 * @whitelistPatterns ['btn']
 * @whitelistPatternsChildren ['alert']
 * @keyFrames true
 * @fontFace true
 */
@import "~Root/node_modules/bootstrap/dist/css/bootstrap.css";

:host {
  display: inline-block;
}

Package Sidebar

Install

npm i @aofl/webcomponent-css-loader

Weekly Downloads

134

Version

3.5.0

License

MIT

Unpacked Size

7.41 kB

Total Files

6

Last publish

Collaborators

  • alexdinari