-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvite.config.js
134 lines (130 loc) · 5.93 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
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
122
123
124
125
126
127
128
129
130
131
132
133
134
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import react from '@vitejs/plugin-react';
import { v4wp } from '@kucrut/vite-for-wp';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
import { wp_scripts } from '@kucrut/vite-for-wp/plugins';
import wasm from 'vite-plugin-wasm';
import topLevelAwait from 'vite-plugin-top-level-await';
import path from 'path';
import svgr from 'vite-plugin-svgr';
import Icons from 'unplugin-icons/vite';
import IconsResolver from 'unplugin-icons/resolver';
import Components from 'unplugin-vue-components/vite';
import httpsImports from 'vite-plugin-https-imports';
export default defineConfig({
plugins: [
wasm(),
topLevelAwait(),
nodePolyfills({
// Override the default polyfills for specific modules.
overrides: {
fs: 'memfs', // Since `fs` is not supported in browsers, we can use the `memfs` package to polyfill it.
},
}),
v4wp({
input: {
dashboard: 'assets/apps/dashboard/main.js',
// Tailwind v4
'packages/core/tailwindcss-v4/play/observer': 'assets/packages/core/tailwindcss-v4/play/observer.js',
'packages/core/tailwindcss-v4/play/autocomplete': 'assets/packages/core/tailwindcss-v4/play/autocomplete.js',
'packages/core/tailwindcss-v4/play/sort': 'assets/packages/core/tailwindcss-v4/play/sort.js',
'packages/core/tailwindcss-v4/play/classname-to-css': 'assets/packages/core/tailwindcss-v4/play/classname-to-css.js',
// Tailwind v3
'packages/core/tailwindcss-v3/play/observer': 'assets/packages/core/tailwindcss-v3/play/observer.js',
'packages/core/tailwindcss-v3/play/autocomplete': 'assets/packages/core/tailwindcss-v3/play/autocomplete.js',
'packages/core/tailwindcss-v3/play/sort': 'assets/packages/core/tailwindcss-v3/play/sort.js',
'packages/core/tailwindcss-v3/play/classname-to-css': 'assets/packages/core/tailwindcss-v3/play/classname-to-css.js',
// Integrations
'integration/bricks': 'assets/integration/bricks/main.js',
'integration/breakdance': 'assets/integration/breakdance/main.js',
'integration/oxygen/iframe': 'assets/integration/oxygen/iframe/main.js',
'integration/oxygen/editor': 'assets/integration/oxygen/editor/main.js',
'integration/gutenberg/post-editor': 'assets/integration/gutenberg/post-editor.js',
'integration/gutenberg/site-editor': 'assets/integration/gutenberg/site-editor.js',
'integration/gutenberg/block-editor': 'assets/integration/gutenberg/block-editor.jsx',
'integration/livecanvas': 'assets/integration/livecanvas/main.js',
'integration/builderius': 'assets/integration/builderius/main.js',
},
outDir: 'build',
}),
vue(),
wp_scripts(),
Components({
resolvers: [
IconsResolver(),
],
}),
Icons({ autoInstall: true, scale: 1 }),
svgr({
svgrOptions: {
dimensions: false,
}
}),
react({
jsxRuntime: 'classic',
}),
httpsImports.default({}, function resolver(matcher) {
return (id, importer) => {
if (matcher(id)) {
return id;
}
else if (matcher(importer) && !id.includes('vite-plugin-node-polyfills')) {
return new URL(id, importer).toString();
}
return undefined;
};
}),
],
build: {
// target: 'modules',
sourcemap: false,
// rollupOptions: {
// output: {
// manualChunks: {
// 'monaco-editor': ['monaco-editor'],
// },
// chunkFileNames: (chunkInfo) => {
// // add .min to the vendor module to exclude it from the `wp i18n make-pot` command.
// // @see https://developer.wordpress.org/cli/commands/i18n/make-pot/
// return chunkInfo.name !== 'plugin' && chunkInfo.moduleIds.some(id => id.includes('assets') && !id.includes('node_modules')) ? '[name]-[hash].js' : '[name]-[hash].min.js';
// },
// },
// plugins: [
// {
// name: 'rename-workers',
// generateBundle(_, bundle) {
// // if the fila name is in the format of `*.worker-*.js` and doesn't have '.min.js`, rename it to `*.worker-*.min.js`
// // @see https://developer.wordpress.org/cli/commands/i18n/make-pot/
// const workerFiles = Object.keys(bundle).filter(file => file.includes('.worker-') && !file.includes('.min.js'));
// workerFiles.forEach((file) => {
// const newFileName = file.replace('.js', '.min.js');
// bundle[newFileName] = { ...bundle[file], fileName: newFileName };
// delete bundle[file];
// });
// }
// }
// ],
// },
},
css: {
preprocessorOptions: {
scss: {
api: 'modern-compiler',
},
},
},
publicDir: 'assets/static',
resolve: {
alias: {
'~': path.resolve(__dirname), // root directory
'@/dashboard': path.resolve(__dirname, './assets/apps/dashboard'),
'@/integration': path.resolve(__dirname, './assets/integration'),
'@/common': path.resolve(__dirname, './assets/common'),
'@/packages': path.resolve(__dirname, './assets/packages'),
},
},
server: {
cors: true,
}
});