forked from rxx-lab/xhs-download-script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
91 lines (91 loc) · 2.7 KB
/
vite.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import monkey, { cdn, util } from 'vite-plugin-monkey'
import { resolve } from 'path'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
AutoImport({
// 自动导入 Vue 相关函数,如:ref, reactive, toRef 等
imports: ['vue'],
resolvers: [
// 自动导入 Element Plus 相关函数,如:ElMessage, ElMessageBox... (带样式)
ElementPlusResolver({
importStyle: 'sass',
}),
],
}),
Components({
resolvers: [
// 自动注册 Element Plus 组件
ElementPlusResolver({
importStyle: 'sass',
}),
],
}),
monkey({
entry: 'src/main.ts',
userscript: {
icon: 'https://picasso-static.xiaohongshu.com/fe-platform/f43dc4a8baf03678996c62d8db6ebc01a82256ff.png',
author: 'x',
description: '小红书图片、视频、实况下载',
namespace: '[email protected]',
match: [
'https://www.xiaohongshu.com/*',
'https://www.xiaohongshu.com/explore/*',
],
name: '小红书下载助手',
license: 'MIT',
'run-at': 'document-end',
version: '1.0.0',
// connect: ['localhost'],
},
build: {
externalGlobals: {
vue: cdn
.jsdelivr('Vue', 'dist/vue.global.prod.min.js')
.concat(util.dataUrl(';window.Vue=Vue;window.VueDemi=Vue;')),
dayjs: cdn.jsdelivr('dayjs', 'dayjs.min.js'),
'dayjs/plugin/timezone': cdn.jsdelivr(
'dayjs_plugin_timezone',
'plugin/timezone.min.js'
),
'dayjs/plugin/utc': cdn.jsdelivr(
'dayjs_plugin_utc',
'plugin/utc.min.js'
),
streamsaver: cdn
.jsdelivr('StreamSaver', 'StreamSaver.js')
.concat(util.dataUrl(';window.StreamSaver=streamSaver;')),
pinia: cdn
.jsdelivr('Pinia', 'dist/pinia.iife.prod.js')
.concat(util.dataUrl(';window.Pinia=Pinia;')),
'pinia-plugin-persistedstate': cdn.jsdelivr(
'piniaPluginPersistedstate',
'dist/index.global.js'
),
},
},
}),
],
resolve: {
alias: {
'@': resolve(__dirname, './src'),
},
},
css: {
preprocessorOptions: {
scss: {
api: 'modern-compiler',
additionalData: `@use "@/style/element.scss" as *;`,
},
},
},
// build: {
// minify: true,
// },
})