-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.lib.js
81 lines (79 loc) · 1.7 KB
/
vite.config.lib.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
72
73
74
75
76
77
78
79
80
81
import { defineConfig, normalizePath } from 'vite';
import { svelte } from '@sveltejs/vite-plugin-svelte';
import babel from '@rollup/plugin-babel';
import resolve from '@rollup/plugin-node-resolve';
import injectProcessEnv from 'rollup-plugin-inject-process-env';
import { viteStaticCopy } from 'vite-plugin-static-copy'
import path from 'node:path';
function getPath(relativePath) {
return normalizePath(path.resolve(__dirname, relativePath));
}
export default defineConfig({
plugins: [
svelte({
configFile: './svelte.config.js'
}),
viteStaticCopy({
targets: [
{
src: getPath('node_modules/@fortawesome/fontawesome-free/css/(fontawesome|regular|solid|brands).min.css'),
dest: getPath('static/fontawesome/css')
},
{
src: getPath('node_modules/@fortawesome/fontawesome-free/webfonts/*'),
dest: getPath('static/fontawesome/webfonts')
}
]
})
],
build:
{
emptyOutDir: true,
outDir: 'build',
lib: {
entry: 'src/lib/index.ts',
name: 'SvelteBundle',
formats: ['iife'],
fileName: () => 'bundle.js'
},
target: 'es2015',
minify: 'esbuild',
sourcemap: true,
rollupOptions: {
plugins: [
resolve(),
babel({
babelHelpers: 'runtime',
exclude:
[
'node_modules/@babel/**',
"node_modules/core-js/**"
],
presets:
[
[
'@babel/preset-env',
{
targets:
{
"ie": "9"
},
useBuiltIns: "usage",
corejs: 3,
forceAllTransforms: true
}
]
],
plugins: [
[
'@babel/plugin-transform-runtime'
]
]
}),
injectProcessEnv({
NODE_ENV: process.env.NODE_ENV,
}),
]
}
}
});