-
Notifications
You must be signed in to change notification settings - Fork 41
/
vite.config.ts
85 lines (83 loc) · 2.08 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
import { lingui } from '@lingui/vite-plugin';
import { VitePWA } from 'vite-plugin-pwa'
import pluginRewriteAll from 'vite-plugin-rewrite-all'
import inject from '@rollup/plugin-inject';
import react from '@vitejs/plugin-react';
import * as fs from 'fs';
import path from 'path';
import { defineConfig } from 'vite';
import checker from 'vite-plugin-checker';
import svgr from 'vite-plugin-svgr';
import topLevelAwait from 'vite-plugin-top-level-await';
import wasm from 'vite-plugin-wasm';
// https://vitejs.dev/config/
export default defineConfig({
// This changes the output dir from dist to build
// comment this out if that isn't relevant for your project
build: {
outDir: 'build',
rollupOptions: {
plugins: [inject({ Buffer: ['buffer', 'Buffer'], process: 'process' })],
},
},
plugins: [
pluginRewriteAll(),
react({
babel: {
plugins: ['macros'],
},
}),
checker({
typescript: true,
eslint: {
lintCommand: 'eslint --ext .js,.ts,.tsx src',
},
}),
lingui(),
wasm(),
topLevelAwait(),
svgr({ svgrOptions: { icon: true } }),
reactVirtualized(),
VitePWA({
registerType: 'autoUpdate',
workbox: {
globPatterns: ['**/*.{js,css,html,ico,png,svg}']
}
})
],
resolve: {
alias: [
{
find: /^~(.*)$/,
replacement: '$1',
},
],
},
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
},
},
},
server: {
port: 3000,
},
});
const WRONG_CODE = `import { bpfrpt_proptype_WindowScroller } from "../WindowScroller.js";`;
export function reactVirtualized() {
return {
name: 'my:react-virtualized',
configResolved() {
const file = require
.resolve('react-virtualized')
.replace(
path.join('dist', 'commonjs', 'index.js'),
path.join('dist', 'es', 'WindowScroller', 'utils', 'onScroll.js'),
);
const code = fs.readFileSync(file, 'utf-8');
const modified = code.replace(WRONG_CODE, '');
fs.writeFileSync(file, modified);
},
};
}