This repository has been archived by the owner on Feb 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
97 lines (93 loc) · 2.62 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
92
93
94
95
96
97
import react from "@vitejs/plugin-react";
import * as path from "node:path";
import { defineConfig, splitVendorChunkPlugin } from "vite";
import { VitePWA as vitePwaPlugin } from "vite-plugin-pwa";
const PRODUCTION = "production";
const DEVELOPMENT = "development";
const environment = process.env.NODE_ENV === PRODUCTION ? PRODUCTION : DEVELOPMENT;
const is_production = environment === PRODUCTION;
const root = `${process.cwd()}/src`;
const dist = `${process.cwd()}/dist`;
export default defineConfig({
build: {
assetsDir: "assets",
chunkSizeWarningLimit: 500,
emptyOutDir: true,
minify: is_production ? "terser" : undefined,
outDir: dist,
rollupOptions: {
input: {
index: `${path.resolve(root, "index.html")}/`,
},
output: {
assetFileNames: is_production ? "assets/[hash][extname]" : "assets/[name]-[hash][extname]",
chunkFileNames: is_production ? "assets/[hash].js" : "assets/[name]-[hash].js",
entryFileNames: "assets/[name].[hash].js",
manualChunks: {
vendor: ["react", "react-dom", "wouter"],
emotion: ["@emotion/css", "@emotion/react", "@emotion/styled", "twin.macro"],
},
},
},
terserOptions: is_production
? {
compress: {
drop_console: true,
},
}
: undefined,
},
plugins: [
react({
babel: {
plugins: [
"babel-plugin-macros",
[
"@emotion/babel-plugin-jsx-pragmatic",
{
export: "jsx",
import: "__cssprop",
module: "@emotion/react",
},
],
["@babel/plugin-transform-react-jsx", { pragma: "__cssprop" }, "twin.macro"],
],
},
}),
vitePwaPlugin({
registerType: "autoUpdate",
workbox: {
inlineWorkboxRuntime: true,
},
manifest: {
name: "Re:ROAD",
short_name: "Re:ROAD",
icons: [
{
src: "/seo/android-chrome-192x192.png",
sizes: "192x192",
type: "image/png",
},
{
src: "/seo/android-chrome-512x512.png",
sizes: "512x512",
type: "image/png",
},
],
theme_color: "#ffcb00",
background_color: "#ffcb00",
start_url: "https://reroad.site/",
display: "standalone",
description: "Re:ROAD、それぞれが色付けた3年ぶりの鈴鹿高専祭。",
lang: "ja",
},
}),
splitVendorChunkPlugin(),
],
root,
envDir: process.cwd(),
publicDir: `${process.cwd()}/public`,
server: {
port: 3000,
},
});