Skip to content

Commit 8afb0ee

Browse files
committed
fix vue plugin demo
1 parent 31742f9 commit 8afb0ee

File tree

3 files changed

+38
-22
lines changed

3 files changed

+38
-22
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ node_modules
1111
.DS_Store
1212
dist
1313
dist-ssr
14+
demo
1415
coverage
1516
*.local
1617

package.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,15 @@
1313
"useragent",
1414
"vue"
1515
],
16+
"publishConfig": {
17+
"access": "public"
18+
},
1619
"type": "module",
1720
"license": "MIT",
1821
"scripts": {
1922
"dev": "vite",
20-
"build": "vue-tsc && vite build",
23+
"build": "vue-tsc && vite build --mode prod",
24+
"demo:build": "vue-tsc && vite build --mode demo",
2125
"preview": "vite preview"
2226
},
2327
"main": "./dist/vue3-device-detect.umd.min.js",

vite.config.ts

+32-21
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,38 @@ import { resolve } from 'path'
33
import vue from '@vitejs/plugin-vue'
44

55
// https://vitejs.dev/config/
6-
export default defineConfig({
7-
plugins: [vue()],
8-
build: {
9-
lib: {
10-
// Could also be a dictionary or array of multiple entry points
11-
entry: resolve(__dirname, 'lib/index.ts'),
12-
name: 'Vue3DeviceDetect',
13-
// the proper extensions will be added
14-
fileName: 'vue3-device-detect',
15-
},
16-
rollupOptions: {
17-
// make sure to externalize deps that shouldn't be bundled
18-
// into your library
19-
external: ['vue'],
20-
output: {
21-
// Provide global variables to use in the UMD build
22-
// for externalized deps
23-
globals: {
24-
vue: 'Vue',
6+
export default defineConfig(({ command, mode }) => {
7+
if (mode === "prod") {
8+
return {
9+
plugins: [vue()],
10+
build: {
11+
lib: {
12+
// Could also be a dictionary or array of multiple entry points
13+
entry: resolve(__dirname, "lib/index.ts"),
14+
name: "Vue3DeviceDetect",
15+
// the proper extensions will be added
16+
fileName: "vue3-device-detect",
17+
},
18+
rollupOptions: {
19+
// make sure to externalize deps that shouldn't be bundled
20+
// into your library
21+
external: ["vue"],
22+
output: {
23+
// Provide global variables to use in the UMD build
24+
// for externalized deps
25+
globals: {
26+
vue: "Vue",
27+
},
28+
},
2529
},
2630
},
27-
},
28-
},
31+
};
32+
} else {
33+
return {
34+
plugins: [vue()],
35+
build: {
36+
outDir: "demo"
37+
}
38+
};
39+
}
2940
})

0 commit comments

Comments
 (0)