-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.ts
121 lines (119 loc) · 2.39 KB
/
vite.config.ts
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import filterReplace from 'vite-plugin-filter-replace';
import * as sass from 'sass'
const lottieScopeVariables = [
'value',
'content',
'loopOut',
'numKeys',
'$bm_mul',
'$bm_sum',
'$bm_sub',
'$bm_div',
'$bm_mod',
'$bm_isInstanceOfArray',
'$bm_transform',
'anchorPoint',
'time',
'velocity',
'inPoint',
'outPoint',
'width',
'height',
'name',
'loop_in',
'loop_out',
'smooth',
'toComp',
'fromCompToSurface',
'toWorld',
'fromWorld',
'mask',
'position',
'rotation',
'scale',
'thisComp',
'active',
'wiggle',
'loopInDuration',
'loopOutDuration',
'comp',
'lookAt',
'easeOut',
'easeIn',
'ease',
'nearestKey',
'key',
'text',
'textIndex',
'textTotal',
'selectorValue',
'framesToTime',
'timeToFrames',
'sourceRectAtTime',
'substring',
'substr',
'posterizeTime',
'index',
'globalData',
'frames',
'$bm_neg',
'add',
'clamp',
'radians_to_degrees',
'degreesToRadians',
'degrees_to_radians',
'normalize',
'rgbToHsl',
'hslToRgb',
'linear',
'random',
'createPath',
'_lottieGlobal',
'transform',
'effect',
'thisProperty',
'loopIn',
'fromComp',
'thisLayer',
'valueAtTime',
'velocityAtTime',
];
// https://vite.dev/config/
export default defineConfig({
publicDir: __dirname + '/public',
plugins: [
react(),
// workaround for a warning with lottie https://github.com/airbnb/lottie-web/issues/2927
filterReplace([
{
filter: ['node_modules/lottie-web/build/player/lottie.js'],
replace: {
from: 'eval(\'[function _expression_function(){\' + val + \';scoped_bm_rt=$bm_rt}]\')[0]',
to: `
function _expression_function() {
var valToEval = val;
scoped_bm_rt = (new Function(
'valToEval', ${lottieScopeVariables.map((v) => `'${v}'`).join(',')},
'try {'
+ val + \`;
return $bm_rt;
} catch (e) {
console.error("Error in lottie-web workaround. Fix the issue in vite.config.ts:", e, "Failed expression:", valToEval);
throw e;
}\`
))(valToEval, ${lottieScopeVariables.join(',')});
}`,
},
},
]),
],
css: {
preprocessorOptions: {
scss: {
implementation: sass,
},
},
},
});