-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
83 lines (80 loc) · 2.37 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
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import {createVuedcoPlugin,initPlugin} from "./doc";
import vueJsx from '@vitejs/plugin-vue-jsx'
import path from "path";
import { namingFormat} from "../vite-build/dist/hooks/index";
const pkg = require("../../../package.json");
const registerName = namingFormat.toHump(pkg.name.replace(/\@tinymce-plugin\//, ''))
const pluginName = namingFormat.toHyphen(pkg.name.replace(/\@tinymce-plugin\//, ''))
// console.log(registerName);
const pathResolve = (pathStr:string) => {
return path.resolve(__dirname, pathStr);
};
let aliasList =[
{find: "/@", replacement: pathResolve('./src')},
{find: "vue", replacement: 'vue/dist/vue.esm-bundler.js'},
{find: "/@tools/", replacement: pathResolve('./tools/')},
]
aliasList.push({find: `@tinymce-plugin/${pluginName}/`,replacement: pathResolve('../../../dist/')})
aliasList.push({find: `@npkg/tinymce-plugin`,replacement: pathResolve('./tinymce-plugin')})
aliasList.push({find: `tinymce-plugin`,replacement: pathResolve('./tinymce-plugin')})
// https://vitejs.dev/config/
export default defineConfig(async({ command, mode })=>{
// createRedirect(__dirname)/
await initPlugin(registerName)
return {
// base: '/build-docs/',
server: {
host: '0.0.0.0',
port: 8999,
// 是否开启 https
https: false,
server:{
hmr:{
overlay: false
}
},
fs: {
// 可以为项目根目录的上一级提供服务
allow: [pathResolve('../../../__docs__'),pathResolve('../../../dist'),pathResolve('./'),pathResolve('./packages')]
}
},
css: {
preprocessorOptions: {
scss: {
additionalData: `
$fontColor: #333;
$themeColor: #35495E;
$themeBrightColor: #43B984;
`
}
}
},
resolve:{
alias: aliasList,
extensions:[ '.mjs', '.js', '.ts', '.jsx', '.tsx', '.json','.md']
},
build:{
chunkSizeWarningLimit: 2000,
minify: true,
sourcemap: false,
brotliSize: false,
},
plugins: [
// myPlugin(),
createVuedcoPlugin({
docsPath(root) {
return "/__docs__"
},
// command: command,
mode: mode,
root: path.join(__dirname)
}),
vue(), vueJsx(),
],
define: {
__INTLIFY_PROD_DEVTOOLS__: false,
}
}
})