Skip to content

Commit

Permalink
feat: exclude Vite direct style tags by default
Browse files Browse the repository at this point in the history
  • Loading branch information
umbopepato committed Jun 21, 2023
1 parent cc82f4c commit 9688624
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,27 @@ import myStyles from './styles.css?inline';
```javascript
postcssLit({

// A glob (or array of globs) of files to include.
// Default: **/*.{css,sss,pcss,styl,stylus,sass,scss,less}
/**
* A glob (or array of globs) of files to include
*
* @default '**‎/*.{css,sss,pcss,styl,stylus,sass,scss,less}?(*)'
*/
include: ...,

// A glob (or array of globs) of files to exclude.
// Default: null
/**
* A glob (or array of globs) of files to exclude
*
* The default filter is used to prevent `<style>` HTML tags from being processed in Vite contexts
* @default '**‎/*\?direct*'
*/
exclude: ...,

// A string denoting the name of the package from which to import the `css`
// template tag function. For lit-element this can be changed to 'lit-element'
// Default: 'lit'
/**
* A string denoting the name of the package from which to import the `css`
* template tag function. For lit-element this can be changed to 'lit-element'
*
* @default 'lit'
*/
importPackage: ...,
}),
```
Expand Down
16 changes: 10 additions & 6 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,25 @@ import {PluginOption} from 'vite';

interface PostcssLitOptions {
/**
* A glob (or array of globs) of files to include.
* @default: '** /*.{css,sss,pcss,styl,stylus,sass,scss,less}'
* A glob (or array of globs) of files to include
*
* @default: '**&#47;*.{css,sss,pcss,styl,stylus,sass,scss,less}?(*)'
*/
include?: string | string[];

/**
* A glob (or array of globs) of files to exclude.
* @default: null
* A glob (or array of globs) of files to exclude
*
* The default filter is used to prevent `<style>` HTML tags from being processed in Vite contexts
* @default '**&#47;*\?direct*'
*/
exclude?: string | string[];

/**
* A string denoting the name of the package from which to import the `css`
* template tag function. For lit-element this can be changed to 'lit-element'
* @default: 'lit'
*
* @default 'lit'
*/
importPackage?: string;
}
Expand All @@ -30,7 +34,7 @@ const escape = (str: string): string => str
export = function postcssLit(options: PostcssLitOptions = {}): PluginOption {
const defaultOptions: PostcssLitOptions = {
include: '**/*.{css,sss,pcss,styl,stylus,sass,scss,less}?(*)',
exclude: null,
exclude: '**/*\?direct*',
importPackage: 'lit',
};

Expand Down

0 comments on commit 9688624

Please sign in to comment.