-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
67 lines (65 loc) · 2.18 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
/* eslint-disable */
import { createHash } from 'node:crypto';
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
import svgr from 'vite-plugin-svgr';
export default defineConfig({
server: {
port: process.env.port ? parseInt(process.env.port, 10) : 3000,
},
// https://github.com/vitejs/vite/issues/1973#issuecomment-787571499
// Using the define option over import.meta because the Node part our universal app cannot handle import.meta yet.
// See also src/mijnamsterdam.d.ts
define: {
MA_OTAP_ENV: JSON.stringify(process.env.MA_OTAP_ENV || 'development'),
MA_APP_MODE: JSON.stringify(process.env.MA_APP_MODE || 'production'),
MA_APP_VERSION: JSON.stringify(
process.env.MA_RELEASE_VERSION_TAG || 'notset'
),
MA_BUILD_ID: JSON.stringify(process.env.MA_BUILD_ID || '-1'),
MA_GIT_SHA: JSON.stringify(process.env.MA_GIT_SHA || '-1'),
},
envPrefix: 'REACT_APP_',
build: {
outDir: 'build',
sourcemap: true,
target: 'es2015',
},
test: {
globals: true,
environment: 'jsdom', // NOTE: overridden with 'node' when testing bff application
setupFiles: './src/testing/setup.ts',
css: false,
},
plugins: [
react(),
// insert eslint plugin when errors are dealt with
// eslint({
// overrideConfigFile: path.resolve(__dirname, 'eslint.config.mjs'),
// }),
// svgr options: https://react-svgr.com/docs/options/
svgr(),
],
css: {
preprocessorOptions: {
scss: {
additionalData: '@use "./src/client/styles/_global.scss" as *;',
silenceDeprecations: ['import', 'legacy-js-api'],
},
},
modules: {
scopeBehaviour: 'local',
// Generate correct CSS name that matches the Create React App one. Some Styles depend on these generated class names.
generateScopedName: function (name, filename) {
const path = require('path');
let file = path.basename(filename);
file = file.split('.')[0];
const hashFunc = createHash('md5');
hashFunc.update(filename);
const hash = btoa(hashFunc.digest('hex')).substring(0, 5);
return file + '_' + name + '__' + hash;
},
},
},
});
/* eslint-enable */