Skip to content

Commit

Permalink
chore(nuxt): module related minor changes & docs update
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-solanki committed Dec 16, 2022
1 parent 6f3c3c1 commit 23100e9
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 60 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ignore-workspace-root-check=true
shamefully-hoist=true
44 changes: 41 additions & 3 deletions docs/guide/getting-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

```bash
# pnpm
pnpm add anu-vue && pnpm add -D @anu-vue/preset-theme-default unocss @iconify-json/bx
pnpm add anu-vue @anu-vue/preset-theme-default && pnpm add -D unocss @iconify-json/bx

# yarn
yarn add anu-vue && yarn add -D @anu-vue/preset-theme-default unocss @iconify-json/bx
yarn add anu-vue @anu-vue/preset-theme-default && yarn add -D unocss @iconify-json/bx

# npm
npm install anu-vue && npm install -D @anu-vue/preset-theme-default unocss @iconify-json/bx
npm install anu-vue @anu-vue/preset-theme-default && npm install -D unocss @iconify-json/bx
```

## Usage
Expand Down Expand Up @@ -180,6 +180,44 @@ You can also follow À la carte fashion if you don't want to register all the co
</template>
```

## Nuxt

1. instead of installing `anu-vue` package, install `@anu-vue/nuxt`.

```bash
# pnpm
pnpm add @anu-vue/nuxt

# yarn
yarn add @anu-vue/nuxt

# npm
npm install @anu-vue/nuxt
```

2. Add Anu & UnoCSS in nuxt modules

```ts
import { defineNuxtConfig } from 'nuxt/config'

export default defineNuxtConfig({
modules: ['@anu-vue/nuxt', '@unocss/nuxt'],
})
```

3. Add UnoCSS config file `uno.config.js` as shown in step 2 of [usage](#usage) section.

4. If you are using `preset-theme-default` [preset](/guide/features/presets.md), You also have to add its CSS (Assuming you already added `preset-theme-default` in `uno.config.js` as preset)

```diff
import { defineNuxtConfig } from 'nuxt/config'

export default defineNuxtConfig({
modules: ['@anu-vue/nuxt', '@unocss/nuxt'],
+ css: ['@anu-vue/preset-theme-default/dist/styles.css'],
})
```

## Volar Support

If you are using [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar), you can specify global component types by adding below configuration in your [`jsconfig.json`](https://code.visualstudio.com/docs/languages/jsconfig).
Expand Down
54 changes: 2 additions & 52 deletions packages/anu-nuxt/README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,3 @@
# @anu-vue/nuxt

## Install

### pnpm
```
pnpm add @anu-vue/nuxt && pnpm add -D @unocss/nuxt @iconify-json/bx
```

### Add to nuxt.config.ts
```ts
export default {
modules: [
'@anu-vue/nuxt',
'@unocss/nuxt',
],
}
```

## Create Config File
unocss.config.ts

```ts
import type { UnocssNuxtOptions } from '@unocss/nuxt'
import presetIcons from '@unocss/preset-icons'
import presetUno from '@unocss/preset-uno'
import { presetCore, presetThemeDefault } from 'anu-vue'

export default <UnocssNuxtOptions>{
preflight: false,
presets: [
presetUno(),
presetIcons({
scale: 1.2,
extraProperties: {
'height': '1.5em',
'flex-shrink': '0',
'display': 'inline-block',
},
}),

// anu-vue presets
presetCore(),
presetThemeDefault(),
],
include: [/.*\/anu-nuxt\.js(.*)?$/, './**/*.vue', './**/*.md'],
}
```



## 💚 Credits

Library Write [productdevbook](https://github.com/productdevbook)
Please refer to the official [docs](https://anu-vue.netlify.app/guide/getting-started/installation.html#nuxt) for the details.
1 change: 1 addition & 0 deletions packages/anu-nuxt/playground/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ import anu from '..'

export default defineNuxtConfig({
modules: [anu, '@unocss/nuxt'],
css: ['@anu-vue/preset-theme-default/dist/styles.scss'],
})
1 change: 1 addition & 0 deletions packages/anu-nuxt/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"private": true,
"name": "my-module-playground",
"devDependencies": {
"@anu-vue/preset-theme-default": "workspace:^0.11.0",
"@iconify-json/bx": "^1.1.5",
"@unocss/nuxt": "^0.46.5"
}
Expand Down
5 changes: 3 additions & 2 deletions packages/anu-nuxt/playground/unocss.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { presetThemeDefault } from '@anu-vue/preset-theme-default'
import type { UnocssNuxtOptions } from '@unocss/nuxt'
import presetIcons from '@unocss/preset-icons'
import presetUno from '@unocss/preset-uno'
import { presetCore, presetThemeDefault } from 'anu-vue'
import { presetAnu } from 'anu-vue'

export default <UnocssNuxtOptions>{
preflight: false,
Expand All @@ -17,7 +18,7 @@ export default <UnocssNuxtOptions>{
}),

// anu-vue presets
presetCore(),
presetAnu(),
presetThemeDefault(),
],
include: [/.*\/anu-vue\.js(.*)?$/, './**/*.vue', './**/*.md'],
Expand Down
5 changes: 2 additions & 3 deletions packages/anu-nuxt/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ import {

import { name, version } from '../package.json'

export interface ModuleOptions {
}
export interface ModuleOptions {}

export default defineNuxtModule<ModuleOptions>({
meta: {
name,
version,
configKey: 'anuvue',
configKey: 'anuVue',
compatibility: {
nuxt: '^3.0.0',
},
Expand Down

0 comments on commit 23100e9

Please sign in to comment.