Skip to content

Commit

Permalink
Merge branch 'master' into release-next
Browse files Browse the repository at this point in the history
  • Loading branch information
ClarkXia committed Jul 6, 2022
2 parents 82543dd + a27620d commit c0bfade
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
6 changes: 5 additions & 1 deletion packages/plugin-ignore-style/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Changelog

## 0.2.0

- [feat] support custom style regexp

## 0.1.1

- [fix] default style regexp

## 0.1.0

- [feat] init plugin
- [feat] init plugin
14 changes: 13 additions & 1 deletion packages/plugin-ignore-style/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,16 @@ config multi library
}
]]
}
```
```

config custom style regexp

```json
{
"plugins": ["build-plugin-ignore-style", [
{
"rule": "@alifd/next/.*\\.scss"
},
]]
}
```
4 changes: 2 additions & 2 deletions packages/plugin-ignore-style/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build-plugin-ignore-style",
"version": "0.1.1",
"version": "0.1.2",
"description": "plugin for ignore style",
"main": "lib/index.js",
"scripts": {
Expand All @@ -25,4 +25,4 @@
"lib",
"!lib/**/*.map"
]
}
}
5 changes: 3 additions & 2 deletions packages/plugin-ignore-style/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { Plugin } from 'vite';
interface Options {
libraryName: string;
style?: string;
rule?:string;
}

const getStyleRule = (libraryName: string, style = 'style'): string => `${libraryName}/(es|lib)/[-\\w+]+/(${style}|${style}.js|${style}/index.js)$`;
Expand All @@ -17,8 +18,8 @@ const plugin: IPlugin = ({ onGetWebpackConfig, modifyUserConfig, log, context },
const libraryConfigs = Array.isArray(options) ? options : [options];
// default rule for external style
const externalRule = libraryConfigs.map((value) => {
const {libraryName, style = 'style'} = value as unknown as Options;
return getStyleRule(libraryName, style);
const {libraryName, style = 'style', rule} = value as unknown as Options;
return rule??getStyleRule(libraryName, style);
}).join('|');
onGetWebpackConfig((config) => {
config.module
Expand Down

0 comments on commit c0bfade

Please sign in to comment.