-
Notifications
You must be signed in to change notification settings - Fork 195
Expand file tree
/
Copy pathvite.config.js
More file actions
45 lines (41 loc) · 1.19 KB
/
vite.config.js
File metadata and controls
45 lines (41 loc) · 1.19 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
import { dirname, resolve } from 'path';
import { fileURLToPath } from 'url';
import { defineConfig } from 'vite';
import { viteStaticCopy } from 'vite-plugin-static-copy';
import viteExposeGasFunctions from './vite-plugins/gas-expose.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const targets = [
{
src: 'node_modules/apps-script-oauth2/dist/OAuth2.gs',
dest: '.',
rename: { stripBase: true },
},
{ src: 'src/html/*.html', dest: '.', rename: { stripBase: true } },
{ src: 'functions/**/*.js', dest: '.', rename: { stripBase: true } },
{ src: 'appsscript.json', dest: '.', rename: { stripBase: true } },
];
export default defineConfig(({ mode }) => ({
plugins: [viteExposeGasFunctions(), viteStaticCopy({ targets })],
resolve: {
alias: {
'@': resolve(__dirname, './src'),
},
},
build: {
target: 'es2020',
minify: mode !== 'development',
outDir: resolve(__dirname, 'dist'),
emptyOutDir: true,
lib: {
entry: resolve(__dirname, 'src/index.js'),
name: 'app',
formats: ['iife'],
},
rollupOptions: {
output: {
entryFileNames: 'code.js',
},
},
},
}));