Skip to content

Commit

Permalink
refactor(rust-plugins): 💡 Update to camelCase options
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongjie.xue committed Dec 30, 2024
1 parent 8d162af commit 54df5b0
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 44 deletions.
64 changes: 32 additions & 32 deletions rust-plugins/modular-import/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,35 @@ export default defineConfig({
* @type {string}
* @default lib
*/
lib_dir: 'lib',
libDir: 'lib',
/**
* @description The components lib directory
* @type {string}
*/
library_name: "",
libraryName: "",
/**
* @description The UI library name
* @type {boolean}
* @default true
*/
camel2_dash: true,
camel2Dash: true,
/**
* @description style lib directory, default "lib"
* @type {string}
* @default lib
*/
style_lib_dir: 'lib',
styleLibDir: 'lib',
/**
* @description the style library name. e.g. custon-theme => custon-theme/index.css
* @type {string}
*/
style_library_name: '',
styleLibraryName: '',
/**
* @description custom style path
* @type {string}
* @default index.css
*/
style_library_path: 'index.css',
styleLibraryPath: 'index.css',
}],
],
});
Expand All @@ -67,7 +67,7 @@ export default defineConfig({
export default defineConfig({
plugins: [
['@farmfe/plugin-modular-import', {
library_name: 'element-ui',
libraryName: 'element-ui',
}]
],
});
Expand All @@ -86,14 +86,14 @@ import SomeComponent from 'element-ui/lib/SomeComponent';
import 'element-ui/lib/SomeComponent/index.css';
```

#### Set `lib_dir` Usage
#### Set `libDir` Usage

```ts
export default defineConfig({
plugins: [
['@farmfe/plugin-modular-import', {
library_name: 'element-ui',
lib_dir: 'es',
libraryName: 'element-ui',
libDir: 'es',
}]
],
});
Expand All @@ -112,15 +112,15 @@ import SomeComponent from 'element-ui/es/SomeComponent';
import 'element-ui/lib/SomeComponent/index.css';
```

#### Set `camel2_dash` Usage
#### Set `camel2Dash` Usage

```ts
export default defineConfig({
plugins: [
['@farmfe/plugin-modular-import', {
library_name: 'element-ui',
lib_dir: 'es',
camel2_dash: false,
libraryName: 'element-ui',
libDir: 'es',
camel2Dash: false,
}]
],
});
Expand All @@ -139,16 +139,16 @@ import SomeComponent from 'element-ui/es/someComponent';
import 'element-ui/lib/someComponent/index.css';
```

#### Set `style_lib_dir` Usage
#### Set `styleLibDir` Usage

```ts
export default defineConfig({
plugins: [
['@farmfe/plugin-modular-import', {
library_name: 'element-ui',
lib_dir: 'es',
camel2_dash: false,
style_lib_dir: 'lib',
libraryName: 'element-ui',
libDir: 'es',
camel2Dash: false,
styleLibDir: 'lib',
}]
],
});
Expand All @@ -167,17 +167,17 @@ import SomeComponent from 'element-ui/es/someComponent';
import 'element-ui/lib/someComponent/index.css';
```

#### Set `style_library_name` Usage
#### Set `styleLibraryName` Usage

```ts
export default defineConfig({
plugins: [
['@farmfe/plugin-modular-import', {
library_name: 'element-ui',
lib_dir: 'es',
camel2_dash: false,
style_lib_dir: 'lib',
style_library_name: 'theme-default',
libraryName: 'element-ui',
libDir: 'es',
camel2Dash: false,
styleLibDir: 'lib',
styleLibraryName: 'theme-default',
}]
],
});
Expand All @@ -196,18 +196,18 @@ import SomeComponent from 'element-ui/es/someComponent';
import 'element-ui/lib/theme-default/someComponent/index.css';
```

#### Set `style_library_path` Usage
#### Set `styleLibraryPath` Usage

```ts
export default defineConfig({
plugins: [
['@farmfe/plugin-modular-import', {
library_name: 'element-ui',
lib_dir: 'es',
camel2_dash: false,
style_lib_dir: 'lib',
style_library_name: 'theme-default',
style_library_path: 'style/index.css'
libraryName: 'element-ui',
libDir: 'es',
camel2Dash: false,
styleLibDir: 'lib',
styleLibraryName: 'theme-default',
styleLibraryPath: 'style/index.css'
}]
],
});
Expand Down
12 changes: 6 additions & 6 deletions rust-plugins/modular-import/options.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export interface IPluginOptions {
library_name: string,
lib_dir?: string,
camel2_dash?: boolean,
style_lib_dir?: string,
style_library_name?: boolean,
style_library_path?: string,
libraryName: string,
libDir?: string,
camel2Dash?: boolean,
styleLibDir?: string,
styleLibraryName?: boolean,
styleLibraryPath?: string,
}
12 changes: 6 additions & 6 deletions rust-plugins/modular-import/playground/farm.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ export default defineConfig({
vitePlugins: [vue()],
plugins: [
['@farmfe/plugin-modular-import', {
library_name: 'element-ui',
lib_dir: 'lib',
camel2_dash: false,
style_lib_dir: 'lib',
style_library_name: 'theme-chalk',
style_library_path: '.css'
libraryName: 'element-ui',
libDir: 'lib',
camel2Dash: false,
styleLibDir: 'lib',
styleLibraryName: 'theme-chalk',
styleLibraryPath: '.css'
}]
],
});
1 change: 1 addition & 0 deletions rust-plugins/modular-import/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use serde::Deserialize;
use std::fmt::Debug;

#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Options {
pub library_name: Option<String>, // library name, default ""
#[serde(default = "default_lib_dir")]
Expand Down

0 comments on commit 54df5b0

Please sign in to comment.