Skip to content

Commit cdd25b7

Browse files
authored
fix: css inject during SSR dev, replace @vueuse/head with @unhead/vue, use unbuild instead of rollup (#2)
1 parent 41708ee commit cdd25b7

File tree

15 files changed

+1556
-345
lines changed

15 files changed

+1556
-345
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
node_modules
33
pnpm-debug.log*
44
dist
5+
.idea

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
18
1+
20

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Vite plugin to develop Vue SSR apps
66
* Vue Router
77
* State management
88
* Teleports
9-
* Document head management (powered by [@vueuse/head](https://github.com/vueuse/head))
9+
* [Unhead](https://unhead.unjs.io) support
1010

1111
## Quick Setup
1212

build.config.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { defineBuildConfig } from 'unbuild'
2+
3+
export default defineBuildConfig({
4+
entries: [
5+
{
6+
input: './src/index.ts',
7+
outDir: './dist',
8+
},
9+
{
10+
input: 'src/plugin/index.ts',
11+
outDir: 'dist/plugin',
12+
}
13+
],
14+
externals: ['express', /@unhead/],
15+
clean: true,
16+
declaration: true,
17+
rollup: {
18+
esbuild: {
19+
minify: true,
20+
},
21+
},
22+
})

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"build:server": "vite build --ssr src/main.ts --outDir dist/server"
1111
},
1212
"dependencies": {
13-
"@vueuse/head": "^1.3.1",
13+
"@unhead/vue": "^1.8.9",
1414
"cookie-parser": "^1.4.6",
1515
"express": "^4.18.2",
1616
"pinia": "^2.1.7",

example/src/App.vue

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
<script setup lang="ts">
2+
import { useHead } from '@unhead/vue'
3+
4+
useHead({
5+
title: 'Example app, using vite-plugin-vue-ssr'
6+
})
7+
</script>
8+
19
<template>
2-
<router-view></router-view>
10+
<RouterView />
311
</template>
12+
13+
<style>
14+
body {
15+
background: yellow;
16+
}
17+
</style>

example/src/main.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { vueSSR } from 'vite-plugin-vue-ssr'
22
import { createPinia } from 'pinia'
3-
43
import App from '@/App.vue'
54

65
const Counter = () => import('@/Counter.vue')

package.json

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@
1313
},
1414
"exports": {
1515
".": {
16-
"import": "./dist/index.js",
16+
"import": "./dist/index.mjs",
1717
"types": "./dist/index.d.ts"
1818
},
1919
"./plugin": {
20-
"import": "./dist/plugin/index.js",
20+
"import": "./dist/plugin/index.mjs",
2121
"types": "./dist/plugin/index.d.ts"
2222
}
2323
},
2424
"files": [
2525
"dist"
2626
],
2727
"scripts": {
28-
"build": "rollup -c",
29-
"dev": "rollup -w -c",
28+
"dev": "unbuild --stub",
29+
"build": "unbuild",
3030
"test": "echo \"Error: no test specified\" && exit 1"
3131
},
3232
"keywords": [
@@ -41,24 +41,20 @@
4141
"@babel/types": "^7.23.3",
4242
"@nuxt/devalue": "^2.0.2",
4343
"@types/express": "^4.17.21",
44-
"@unhead/schema": "^1.8.3",
4544
"cheerio": "1.0.0-rc.12",
4645
"cookie-parser": "^1.4.6"
4746
},
4847
"devDependencies": {
4948
"@types/node": "^18.18.9",
50-
"@vueuse/head": "^1.3.1",
51-
"esbuild": "^0.17.19",
52-
"rollup": "^3.29.4",
53-
"rollup-plugin-dts": "^5.3.1",
54-
"rollup-plugin-esbuild": "^5.0.0",
49+
"@unhead/vue": "^1.8.9",
5550
"typescript": "^5.1.6",
51+
"unbuild": "^2.0.0",
5652
"vite": "^5.0.0",
5753
"vue": "^3.3.8",
5854
"vue-router": "^4.2.5"
5955
},
6056
"peerDependencies": {
61-
"@vueuse/head": "^1.3.1",
57+
"@unhead/vue": "^1.8.9",
6258
"vite": "^5.0.0",
6359
"vue": "^3.3.8",
6460
"vue-router": "^4.2.5"

0 commit comments

Comments
 (0)