forked from acquia-pso/chn1-search
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
103 lines (102 loc) · 3 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
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
98
99
100
101
102
103
/**
* @file Configures Vite for the project, setting up PostCSS plugins for CSS transformations.
*/
import { defineConfig } from 'vite';
import * as glob from 'glob';
import postcssPresetEnv from 'postcss-preset-env';
import postcssNested from 'postcss-nested';
import postcssNestedImport from 'postcss-nested-import';
import postcssDiscardComments from 'postcss-discard-comments';
import ts from 'vite-plugin-ts';
import { terser } from 'rollup-plugin-terser';
// https://vitejs.dev/config/
export default defineConfig({
base: './',
plugins: [ts()],
define: {
'Reflect.decorate': 'undefined',
},
css: {
postcss: {
plugins: [
/**
* @see https://www.npmjs.com/package/postcss-preset-env
* Applies a set of CSS transformations based on the latest CSS specifications.
*/
postcssPresetEnv({ stage: 1 }),
/**
* @see https://www.npmjs.com/package/postcss-nested
* Allows you to nest style rules inside each other, similar to Sass and Less.
*/
postcssNested(),
/**
* @see https://www.npmjs.com/package/postcss-nested-import
* Enables nested @import statements in CSS.
*/
postcssNestedImport(),
/**
* @see https://www.npmjs.com/package/postcss-discard-comments
* Discards comments in your CSS files during the PostCSS process.
*/
postcssDiscardComments(),
],
},
},
build: {
lib: {
entry: {
// Component Library Bundles
index: 'src/index.ts',
// components: 'src/components/index.ts',
// Individual Component Bundles
// component1: 'src/components/component1.ts',
// component2: 'src/components/component2.ts',
// Add more components as needed.
// ...Object.fromEntries(
// glob
// .sync('src/components/**/*.ts', {
// ignore: ['src/components/index.ts'],
// })
// .map((file) => [
// `components/${file.replace(/^src\/components\/|\.ts$/g, '')}`,
// file,
// ]),
// ),
...Object.fromEntries(
glob
.sync('src/**/*.ts', {
ignore: ['src/components/index.ts', '**/*.d.ts'],
})
.map(file => {
const pathWithoutExtension = file.replace(/\.ts$/, '');
const entryName = pathWithoutExtension.substring(4); // Remove 'src/' prefix
return [entryName, `./${file}`];
})
),
},
formats: [
// 'es' is the default format, modules are bundled to .mjs files
'es',
],
},
rollupOptions: {
plugins: [
terser({
format: {
comments: false,
},
mangle: {
keep_classnames: false,
reserved: [],
},
}),
],
},
minify: 'terser',
sourcemap: true,
target: 'esnext',
TerserOptions: {
maxWorkers: 16,
},
},
});