-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
71 lines (66 loc) · 1.98 KB
/
vite.config.js
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
import { resolve } from "path";
import autoprefixer from "autoprefixer";
import glsl from "vite-plugin-glsl";
import { defineConfig } from "vite";
import * as dotenv from "dotenv";
const result = dotenv.config();
if (result.error) throw result.error;
function createDate() {
const now = new Date(),
year = now.getFullYear(),
month = now.getMonth() + 1,
date = now.getDate();
return `${year}${month}${date}`;
}
const DATE = createDate();
const config = {
root: "src",
dist: "dist",
public: "public",
};
export default defineConfig(({ mode }) => {
console.log(
`// --------------------------\n\n⚡️ ~ MODE : ${mode}\n\n▕▔▔▔▔▔▔▔▔▔▔▔╲\n▕╮╭┻┻╮╭┻┻╮╭▕╮╲\n▕╯┃╭╮┃┃╭╮┃╰▕╯╭▏\n▕╭┻┻┻┛┗┻┻┛ ╰▏ ▏\n▕╰━━━┓┈┈┈╭╮▕╭╮▏\n▕╭╮╰┳┳┳┳╯╰╯▕╰╯▏\n▕╰╯┈┗┛┗┛┈╭╮▕╮┈▏\n\n// --------------------------`,
);
return {
root: config.root,
base: "./",
css: {
postcss: {
plugins: [autoprefixer({ grid: true })],
},
},
publicDir: resolve(__dirname, config.public),
esbuild: {
drop: ["console", "debugger"],
},
build: {
outDir: resolve(__dirname, config.dist),
emptyOutDir: true,
chunkSizeWarningLimit: 100000000,
rollupOptions: {
output: {
entryFileNames: `assets/js/app.${DATE}.js`,
assetFileNames: (assetInfo) => {
if (assetInfo.name === "index.css") {
return `assets/css/app.${DATE}.css`;
}
return `assets/[name].${DATE}.[ext]`;
},
chunkFileNames: `assets/[name].${DATE}.js`,
},
},
},
plugins: [glsl()],
server: {
open: process.env.SITE_DEVE_URL,
port: process.env.PORT,
host: true,
},
preview: {
open: process.env.SITE_DEVE_URL,
port: process.env.PORT,
host: true,
},
};
});