Skip to content

Commit

Permalink
feat: support for disable automatically import styles (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
tolking committed Jun 9, 2023
1 parent 56dedae commit a5ba0f8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ How to load directives and components from lazyload.

eg. `{ lazyComponent: true }`

### importStyle

- Type: `boolean`
- Default: `true`

Whether to automatically import styles.

### excludeExports

- Type: `array`
Expand Down
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const defaultExclude: RegExp[] = [

export const defaults: Options = {
lazyload: false,
importStyle: true,
components: allComponents,
imports: allImports,
excludeExports: defaultExcludeExports,
Expand Down
3 changes: 2 additions & 1 deletion src/core/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ export function getStyleDir (name: string) {
}

export function resolveStyles (config: Options, name: string) {
const { components } = config
const { components, importStyle } = config

if (importStyle === false) { return undefined }
if (name in allImportsWithStyle) {
return getStyleDir(allImportsWithStyle[name])
}
Expand Down
6 changes: 6 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ export interface Options extends TransformOptions {
* ```
*/
lazyload: boolean | { lazyComponent?: boolean; lazyImage?: boolean }
/**
* Whether to automatically import style files.
*
* @default true
*/
importStyle: boolean
/**
* Exclude exports from Vant that are not component content.
*
Expand Down

0 comments on commit a5ba0f8

Please sign in to comment.