-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvite.config.js
More file actions
94 lines (88 loc) · 2.57 KB
/
vite.config.js
File metadata and controls
94 lines (88 loc) · 2.57 KB
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
import { resolve } from "path";
import { defineConfig, loadEnv } from "vite";
import react from "@vitejs/plugin-react";
import banner from "rollup-plugin-banner2";
import terser from "@rollup/plugin-terser";
import packageJson from "./package.json";
const root = resolve(__dirname, "src");
const outDir = resolve(__dirname, "dist");
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
// Load env file based on `mode` in the current working directory.
// Set the third parameter to '' to load all env regardless of the `VITE_` prefix.
const env = loadEnv(mode, process.cwd(), "");
// if command === serve - you can return a development mode specific config
// if command === build - you can return a production mode specific config
const bannerContent = [
`NICE Global Nav ${packageJson.version} | build: ${
env.BUILD_NUMBER || `N/A`
} | ${new Date().toISOString().split("T")[0]}`,
`© Copyright NICE 2015-${new Date().getFullYear()}`,
"Licensed under MIT (https://github.com/nice-digital/global-nav/blob/master/LICENSE)",
].join("\n");
return {
root,
plugins: [react()],
css: {
devSourcemap: true,
},
server: {
port: 3000,
},
build: {
outDir,
emptyOutDir: true,
sourcemap: true,
rollupOptions: {
input: {
main: resolve(root, "index.html"),
},
output: [
{
entryFileNames: "global-nav.min.js", // Set the output file name
chunkFileNames: "[name].[hash].js", // set the chunk file names
assetFileNames: "[name].[hash].[ext]", //set the asset file names
format: "iife", // Or other format like 'umd', 'cjs', etc.
plugins: [
terser({
mangle: true,
compress: {
drop_console: true,
drop_debugger: true,
unsafe: true,
pure_getters: true,
},
output: {
comments: false,
},
toplevel: true,
}),
banner(
() => `/*!\n * ${bannerContent}\n - minified version \n */\n`
),
],
},
{
entryFileNames: "global-nav.js", // Set the output file name
chunkFileNames: "[name].[hash].js", // set the chunk file names
assetFileNames: "[name].[hash].[ext]", //set the asset file names
format: "iife", // Or other format like 'umd', 'cjs', etc.
plugins: [
banner(
() =>
`/*!\n * ${bannerContent}\n - none minified version \n */\n`
),
],
},
],
},
},
test: {
globals: true,
restoreMocks: true,
mockReset: true,
environment: "jsdom",
setupFiles: [resolve(root, "./setupTests.js")],
},
};
});