代码拉取完成,页面将自动刷新
import { crx } from '@crxjs/vite-plugin'
import vue from '@vitejs/plugin-vue'
import { dirname, relative } from 'node:path'
import { URL, fileURLToPath } from 'node:url'
import AutoImport from 'unplugin-auto-import/vite'
import IconsResolver from 'unplugin-icons/resolver'
import Icons from 'unplugin-icons/vite'
import Components from 'unplugin-vue-components/vite'
import { defineConfig } from 'vite'
import Pages from 'vite-plugin-pages'
import { defineViteConfig as define } from './define.config'
import manifest from './manifest.config'
// https://vitejs.dev/config/
export default defineConfig({
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
'~': fileURLToPath(new URL('./src', import.meta.url)),
src: fileURLToPath(new URL('./src', import.meta.url)),
},
},
plugins: [
// legacy({
// targets: ['defaults'],
// }),
crx({
manifest,
browser: 'chrome',
}),
vue(),
Pages({
dirs: [
{
dir: 'src/pages',
baseRoute: '',
},
{
dir: 'src/setup/pages',
baseRoute: 'setup',
},
{
dir: 'src/popup/pages',
baseRoute: 'popup',
},
{
dir: 'src/options/pages',
baseRoute: 'options',
},
{
dir: 'src/content-script/iframe/pages',
baseRoute: 'iframe',
},
],
}),
AutoImport({
imports: ['vue', 'vue-router', 'vue/macros', '@vueuse/core'],
dts: 'src/types/auto-imports.d.ts',
dirs: ['src/composables/', 'src/stores/', 'src/utils/'],
}),
// https://github.com/antfu/unplugin-vue-components
Components({
dirs: ['src/components'],
// generate `components.d.ts` for ts support with Volar
dts: 'src/types/components.d.ts',
resolvers: [
// auto import icons
IconsResolver({
prefix: 'i',
enabledCollections: ['mdi'],
}),
],
}),
// https://github.com/antfu/unplugin-icons
Icons({
autoInstall: true,
compiler: 'vue3',
scale: 1.5,
}),
// rewrite assets to use relative path
{
name: 'assets-rewrite',
enforce: 'post',
apply: 'build',
transformIndexHtml(html, { path }) {
return html.replace(
/"\/assets\//g,
`"${relative(dirname(path), '/assets')}/`
)
},
},
],
build: {
rollupOptions: {
input: {
iframe: 'src/content-script/iframe/index.html',
popup: 'src/popup/index.html',
setup: 'src/setup/index.html',
options: 'src/options/index.html',
},
},
minify: 'terser',
terserOptions: {},
outDir: 'dist/chrome',
},
server: {
port: 8888,
strictPort: true,
hmr: {
port: 8889,
overlay: false,
},
},
optimizeDeps: {
include: ['vue', '@vueuse/core'],
exclude: ['vue-demi'],
},
assetsInclude: ['src/assets/*/**'],
define,
})
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。