-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
67 lines (62 loc) · 1.51 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
import mdPlugin, { Mode } from "vite-plugin-markdown";
import { defineConfig, loadEnv } from "vite";
import Vue from "@vitejs/plugin-vue";
import path from "path";
import EslintPlugin from "vite-plugin-eslint";
import Env from "vite-plugin-env-compatible";
import inject from "@rollup/plugin-inject";
function GraphQl() {
return {
name: "graphql-file",
transform(src, id) {
if (id.endsWith(".graphql") || id.endsWith(".gql")) {
const str = JSON.stringify(src);
return {
code:
"import gql from 'graphql-tag';const doc=" +
str +
"; export default gql`${doc}`",
map: null,
};
}
},
};
}
export default defineConfig(({ mode }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
console.log("Vite:Mode=" + mode);
// const env = Object.assign(process.env, loadEnv(mode, process.cwd()));
return {
build: {
outDir: "dist",
output: { entryFileNames: "[name].css" },
},
optimizeDeps: {
exclude: [],
},
plugins: [
Vue(),
GraphQl(),
Env({
prefix: "",
}),
mdPlugin({ mode: [Mode.HTML] }),
EslintPlugin({
fix: true,
}),
],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
rollupOptions: {
plugins: [inject({ Buffer: ["buffer", "Buffer"] })],
},
commonjsOptions: {
transformMixedEsModules: true,
},
envDir: "./",
publicDir: "./assets",
};
});