1.1.3 • Published 12 months ago

rollup-plugin-template-postcss v1.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

Run Postcss on Template Literals

This plugin iterates through all CSS template literals in your JavaScript files and processes them using PostCSS. It is perfect for LitElement's css template literal.

Installation

npm install --save-dev rollup-plugin-template-postcss postcss

Usage

Options

OptionTypeDefaultDescription
pluginsArray[]PostCSS plugins to use.
includeArray['**/*.js', '**/*.ts']Glob patterns to include.
excludeArray[]Glob patterns to exclude.
tagsArray or String'css'CSS template literal tags to process.

Example

import { templatePostcss } from 'rollup-plugin-template-postcss';

export default {
  // ...
  plugins: [
    // ...
    templatePostcss({
      tags: ['css', 'myCustomCss'], // default is 'css' (optional)
      include: ['**/*.js', '**/*.ts'], // default (optional)
      exclude: [], // default (optional)
      // PostCSS plugins
      plugins: [],
    }),
  ],
};

With nano css and advanced preset

npm install --save-dev cssnano cssnano-preset-advanced
import { templatePostcss } from 'rollup-plugin-template-postcss';
import cssnano from 'cssnano';

export default {
  // ...
  plugins: [
    // ...
    templatePostcss({
      plugins: [
        cssnano({
          preset: [
            'advanced',
            {
              discardComments: {
                removeAll: true,
              },
            },
          ],
        }),
      ],
    }),
  ],
};

With vite

import { templatePostcss } from 'rollup-plugin-template-postcss';

export default {
  //...
  build: {
    rollupOptions: {
      plugins: [
        //...
        templatePostcss({
          plugins: [],
        }),
      ],
    },
  },
};

License

MIT

1.1.3

12 months ago

1.1.2

12 months ago

1.1.1

12 months ago

1.1.0

12 months ago

1.0.5

12 months ago

1.0.4

12 months ago

1.0.3

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago