-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
51 lines (46 loc) · 1.05 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
import { defineConfig } from 'vite';
import assertRemove from 'destam-dom/transform/assertRemove';
import compileHTMLLiteral from 'destam-dom/transform/htmlLiteral';
const createTransform = (name, transform, jsx, options) => ({
name,
transform(code, id) {
if (id.endsWith('.js') || (jsx && id.endsWith('.jsx'))) {
const transformed = transform(code, {
sourceFileName: id,
plugins: id.endsWith('.jsx') ? ['jsx'] : [],
...options,
});
return {
code: transformed.code,
map: transformed.map,
};
}
}
});
const plugins = [];
plugins.push(createTransform('transform-literal-html', compileHTMLLiteral, true, {
jsx_auto_import: {
h: 'destamatic-ui',
raw: {
name: 'h',
location: 'destam-dom'
}
},
}));
if (process.env.ENV === 'production') {
plugins.push(createTransform('assert-remove', assertRemove));
}
export default defineConfig({
root: './frontend',
plugins,
esbuild: {
jsx: 'preserve',
},
base: '',
resolve: {
extensions: ['.js', '.ts', '.tsx', '.jsx'],
},
build: {
outDir: '../build/dist',
},
});