Skip to content

Commit

Permalink
build(vue): add rollup vue plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Rock070 committed Aug 25, 2023
1 parent 777c986 commit 36df109
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 7 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"rollup": "^3.28.0",
"rollup-plugin-dts": "^6.0.0",
"rollup-plugin-typescript2": "^0.35.0",
"rollup-plugin-vue": "^6.0.0",
"simple-git-hooks": "^2.9.0",
"typescript": "^5.1.6",
"vue-tsc": "^1.8.5"
Expand Down
7 changes: 5 additions & 2 deletions packages/core/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { resolve } = require('node:path')
const { dts } = require('rollup-plugin-dts')

const vue = require('rollup-plugin-vue')
const typescript = require('rollup-plugin-typescript2')

const { readJSONSync } = require('fs-extra')
Expand All @@ -25,6 +25,7 @@ module.exports = [
typescript({
clean: true,
}),
vue({ css: true }),
],
output: [
/**
Expand All @@ -51,6 +52,7 @@ module.exports = [
typescript({
clean: true,
}),
vue({ css: true }),
],
output: [
{
Expand All @@ -74,6 +76,7 @@ module.exports = [
typescript({
clean: true,
}),
vue({ css: true }),
],
output: [
{
Expand Down Expand Up @@ -102,6 +105,6 @@ module.exports = [
},
entryFileNames: 'index.d.ts',
}],
plugins: [dts()],
plugins: [typescript({ clean: true }), vue({ css: true }), dts()],
},
]
35 changes: 35 additions & 0 deletions packages/core/src/components/Noti.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<script setup lang="ts">
import { ref } from 'vue'
import { useToggle } from '@vueuse/core'
import type { NotiOptions } from '../types'
export type NotificationList = (NotiOptions & { id: symbol })[]
export interface NotiProps {
test: string
}
defineProps<NotiProps>()
const [open] = useToggle(false)
const notificationList = ref<NotificationList>([])
</script>

<template>
<div v-show="open" class="vue3-noti-group">
<div v-for="noti in notificationList" :key="noti.id" class="vue3-noti-group__item">
message
</div>
</div>
</template>

<!-- <style lang="css">
.vue3-noti-group {
//
}
.vue3-noti-group__item {
//
}
</style> -->
10 changes: 10 additions & 0 deletions packages/core/src/composables/useEventBus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { useEventBus as _useEventBus } from '@vueuse/core'

import type { EventBusKey } from '@vueuse/core'
import type { NotiOptions } from '../types'

export const BUS_KEY: EventBusKey<NotiOptions> = Symbol('busKey')

export default function useEventBus() {
return _useEventBus(BUS_KEY)
}
1 change: 1 addition & 0 deletions packages/core/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './plugins/noti'
export * from './composables/useNoti'
export * from './types'
export { default as Noti } from './components/Noti.vue'
2 changes: 1 addition & 1 deletion packages/core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"],
"include": ["src", "./vite-env.d.ts"],
"exclude": [
"node_modules"
]
Expand Down
8 changes: 8 additions & 0 deletions packages/core/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/// <reference types="vite/client" />

declare module '*.vue' {
import type { DefineComponent } from 'vue';
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
const component: DefineComponent<{}, {}, any>;
export default component;
}
6 changes: 5 additions & 1 deletion playground/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<script setup lang="ts">
import { useNoti } from '@vue3-noti/core'
import { ref } from 'vue'
import { Noti, useNoti } from '@vue3-noti/core'
import HelloWorld from './components/HelloWorld.vue'
const string = ref('')
useNoti()
</script>

Expand All @@ -16,6 +19,7 @@ useNoti()
</a>
</div>
<HelloWorld msg="Vite + Vue" />
<Noti v-model="string" />
</template>

<style scoped>
Expand Down
37 changes: 34 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 36df109

Please sign in to comment.