rollup-plugin-kdu
Version:
Roll .kdu files
126 lines (125 loc) • 4.03 kB
TypeScript
import { ScriptOptions, StyleOptions, TemplateOptions, DescriptorCompileResult } from '@kdujs/component-compiler';
import { Plugin } from 'rollup';
import { KduTemplateCompiler, KduTemplateCompilerParseOptions } from '@kdujs/component-compiler-utils/dist/types';
export interface KduPluginOptionsData {
css: string | (() => string);
less: string | (() => string);
postcss: string | (() => string);
sass: string | (() => string);
scss: string | (() => string);
stylus: string | (() => string);
}
export interface KduPluginOptions {
/**
* Include files or directories.
* @default `'.kdu'`
*/
include?: Array<string | RegExp> | string | RegExp;
/**
* Exclude files or directories.
* @default `undefined`
*/
exclude?: Array<string | RegExp> | string | RegExp;
/**
* Default language for blocks.
*
* @default `{}`
* @example
* ```js
* KduPlugin({ defaultLang: { script: 'ts' } })
* ```
*/
defaultLang?: {
[key: string]: string;
};
/**
* Exclude/Include customBlocks for final build.
* @default `() => false`
* @example
* ```js
* KduPlugin({ customBlocks: ['markdown', '!test'] })
* ```
*/
customBlocks?: string[] | ((tag: string) => boolean);
/**
* Exclude customBlocks for final build.
* @default `['*']`
* @deprecated
* @example
* ```js
* KduPlugin({ blackListCustomBlocks: ['markdown', 'test'] })
* ```
*/
blackListCustomBlocks?: string[];
/**
* Include customBlocks for final build.
* @default `[]`
* @deprecated
* @example
* ```js
* KduPlugin({ blackListCustomBlocks: ['markdown', 'test'] })
* ```
*/
whiteListCustomBlocks?: string[];
/**
* Prepend CSS.
* @default `undefined`
* @example
* ```js
* KduPlugin({ data: { scss: '$color: red;' } }) // to extract css
* ```
*/
data?: Partial<KduPluginOptionsData>;
/**
* Inject CSS in JavaScript.
* @default `true`
* @example
* ```js
* KduPlugin({ css: false }) // to extract css
* ```
*/
css?: boolean;
/**
* Expose filename in __file property.
* @default `false`
* @example
* ```js
* KduPlugin({ exposeFilename: true })
* ```
*/
exposeFilename?: boolean;
compiler?: KduTemplateCompiler;
compilerParseOptions?: KduTemplateCompilerParseOptions;
sourceRoot?: string;
/**
* @@kdujs/component-compiler [#](https://github.com/kdujs/kdu-component-compiler#api) script processing options.
*/
script?: ScriptOptions;
/**
* @@kdujs/component-compiler [#](https://github.com/kdujs/kdu-component-compiler#api) style processing options.
*/
style?: StyleOptions;
/**
* @@kdujs/component-compiler [#](https://github.com/kdujs/kdu-component-compiler#api) template processing options.
*/
template?: TemplateOptions;
/**
* @@kdujs/component-compiler [#](https://github.com/kdujs/kdu-component-compiler#api) module name or global function for custom runtime component normalizer.
*/
normalizer?: string;
/**
* @@kdujs/component-compiler [#](https://github.com/kdujs/kdu-component-compiler#api) module name or global function for custom style injector factory.
*/
styleInjector?: string;
/**
* @@kdujs/component-compiler [#](https://github.com/kdujs/kdu-component-compiler#api) module name or global function for custom style injector factory for SSR environment.
*/
styleInjectorSSR?: string;
styleInjectorShadow?: string;
isWebComponent?: boolean;
beforeAssemble?(descriptor: DescriptorCompileResult): DescriptorCompileResult;
}
/**
* Rollup plugin for handling .kdu files.
*/
export default function kdu(opts?: Partial<KduPluginOptions>): Plugin;