-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: auto import components and variables
- Loading branch information
Showing
13 changed files
with
217 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"useTabs": false, | ||
"tabWidth": 2, | ||
"trailingComma": "none", | ||
"semi": true, | ||
"singleQuote": true, | ||
"vueIndentScriptAndStyle": false, | ||
"printWidth": 250, | ||
"bracketSameLine": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"cSpell.words": ["nuxt", "tdesign"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
<template> | ||
<div> | ||
Nuxt module playground! | ||
<t-button>1</t-button> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
</script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
export default defineNuxtConfig({ | ||
modules: ['../src/module'], | ||
myModule: {}, | ||
build: { | ||
transpile: ['tdesign-vue-next'] | ||
}, | ||
devtools: { enabled: true } | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
export const componentMap = { | ||
// Basic components | ||
button: ['Button', 'ButtonGroup'], | ||
link: ['Link'], | ||
// Layout Components | ||
divider: ['divider'], | ||
grid: ['Row', 'Col'], | ||
layout: ['Layout', 'Header', 'Aside', 'Content', 'Footer'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Module options TypeScript interface definition | ||
export interface ModuleOptions { | ||
/** | ||
* resolve `tdesign-icons' | ||
* @default true | ||
*/ | ||
resolveIcons?: boolean; | ||
/** | ||
* whether to import ESM version | ||
* @default false | ||
*/ | ||
esm?: boolean; | ||
/** | ||
* exclude component name, if match do not resolve the name | ||
* | ||
*/ | ||
exclude?: string | RegExp | (string | RegExp)[]; | ||
/** | ||
* self-defined the component prefix | ||
*/ | ||
prefix?: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
import { defineNuxtModule, addPlugin, createResolver } from '@nuxt/kit' | ||
import { defineNuxtModule, addPlugin, createResolver, tryResolveModule } from '@nuxt/kit'; | ||
|
||
// Module options TypeScript interface definition | ||
export interface ModuleOptions {} | ||
import type { ModuleOptions } from './interface'; | ||
import { resolveTDesignComponents, resolveTDesignVariables } from './resolvers'; | ||
|
||
export default defineNuxtModule<ModuleOptions>({ | ||
meta: { | ||
name: 'TDesign Vue Next Nuxt module', | ||
configKey: 'myModule' | ||
configKey: 'tdesign' | ||
}, | ||
// Default configuration options of the Nuxt module | ||
defaults: {}, | ||
setup (options, nuxt) { | ||
const resolver = createResolver(import.meta.url) | ||
setup(options: ModuleOptions, nuxt) { | ||
const resolver = createResolver(import.meta.url); | ||
|
||
// Do not add the extension since the `.ts` will be transpiled to `.mjs` after `npm run prepack` | ||
addPlugin(resolver.resolve('./runtime/plugin')) | ||
console.log('🚀 tdesign-vue-next nuxt module is loading'); | ||
|
||
resolveTDesignVariables(options, nuxt); | ||
resolveTDesignComponents(options); | ||
} | ||
}) | ||
}); |
Oops, something went wrong.