Repository navigation
Expand file tree
/
Copy pathvite.renderer.shared.js
More file actions
73 lines (70 loc) · 2.38 KB
/
Copy pathvite.renderer.shared.js
File metadata and controls
73 lines (70 loc) · 2.38 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
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
import { resolve } from 'node:path';
import react from '@vitejs/plugin-react';
export const rendererRoot = resolve(__dirname, 'src');
export const sharedRendererConfig = {
root: rendererRoot,
define: {
// Provide module shim for libraries that check module.hot (like redux-form)
'module.hot': 'undefined',
},
resolve: {
alias: {
'@': rendererRoot,
'~': resolve(__dirname, 'node_modules'),
},
},
build: {
commonjsOptions: {
include: [/node_modules/],
transformMixedEsModules: true,
},
dynamicImportVarsOptions: {
// Vite leaves dynamic imports in node_modules untransformed by default.
// protocol-validation loads its validators with
// import(`./schemas/${version}.js`), which then resolves against the
// bundle instead of the package and fails for every protocol
// ("Couldn't find validator for schema version N"). Transform that one
// package so its schema files are bundled as chunks.
exclude: [/^(?!.*\/@codaco\/protocol-validation\/).*\/node_modules\//],
},
// @codaco/ui reads animation settings by JSON.parse-ing CSS custom
// properties (--animation-easing-json: [0.4, 0, 0.2, 1]). The CSS minifier
// shortens those numbers to `.4`, which is not JSON, so every transition
// threw and the mobile (web) build never rendered an interview. Ship CSS
// unminified, as the Electron renderer already does.
cssMinify: false,
},
plugins: [react()],
worker: { format: 'es' },
optimizeDeps: {
// csvtojson's CJS browser build is imported only from csvDecoder.worker.js;
// include it so the dep optimizer pre-bundles it (CJS->ESM) for the worker.
include: [
'react-resize-aware',
'@codaco/ui',
'csvtojson/browser/browser.js',
],
// protocol-validation dynamically imports ./schemas/<version>.js at runtime;
// the dep optimizer can't follow that, so serve it unbundled.
exclude: ['@codaco/protocol-validation'],
},
css: {
preprocessorOptions: {
scss: {
api: 'modern-compiler',
silenceDeprecations: [
'import',
'global-builtin',
'legacy-js-api',
'color-functions',
'slash-div',
'if-function',
],
loadPaths: [
resolve(__dirname, 'src/styles'),
resolve(__dirname, 'node_modules'),
],
},
},
},
};