disable code inspector plugin during build
Browse files- web/vite.config.js +74 -69
web/vite.config.js
CHANGED
|
@@ -25,83 +25,88 @@ import { codeInspectorPlugin } from 'code-inspector-plugin';
|
|
| 25 |
const { vitePluginSemi } = pkg;
|
| 26 |
|
| 27 |
// https://vitejs.dev/config/
|
| 28 |
-
export default defineConfig({
|
| 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 |
});
|
|
|
|
| 25 |
const { vitePluginSemi } = pkg;
|
| 26 |
|
| 27 |
// https://vitejs.dev/config/
|
| 28 |
+
export default defineConfig(({ command }) => {
|
| 29 |
+
const isBuild = command === 'build';
|
| 30 |
+
return {
|
| 31 |
+
resolve: {
|
| 32 |
+
alias: {
|
| 33 |
+
'@': path.resolve(__dirname, './src'),
|
| 34 |
+
},
|
| 35 |
},
|
| 36 |
+
plugins: [
|
| 37 |
+
!isBuild
|
| 38 |
+
? codeInspectorPlugin({
|
| 39 |
+
bundler: 'vite',
|
| 40 |
+
})
|
| 41 |
+
: null,
|
| 42 |
+
{
|
| 43 |
+
name: 'treat-js-files-as-jsx',
|
| 44 |
+
async transform(code, id) {
|
| 45 |
+
if (!/src\/.*\.js$/.test(id)) {
|
| 46 |
+
return null;
|
| 47 |
+
}
|
| 48 |
|
| 49 |
+
// Use the exposed transform from vite, instead of directly
|
| 50 |
+
// transforming with esbuild
|
| 51 |
+
return transformWithEsbuild(code, id, {
|
| 52 |
+
loader: 'jsx',
|
| 53 |
+
jsx: 'automatic',
|
| 54 |
+
});
|
| 55 |
+
},
|
| 56 |
},
|
| 57 |
+
react(),
|
| 58 |
+
vitePluginSemi({
|
| 59 |
+
cssLayer: true,
|
| 60 |
+
}),
|
| 61 |
+
].filter(Boolean),
|
| 62 |
+
optimizeDeps: {
|
| 63 |
+
force: true,
|
| 64 |
+
esbuildOptions: {
|
| 65 |
+
loader: {
|
| 66 |
+
'.js': 'jsx',
|
| 67 |
+
'.json': 'json',
|
| 68 |
+
},
|
| 69 |
},
|
| 70 |
},
|
| 71 |
+
build: {
|
| 72 |
+
rollupOptions: {
|
| 73 |
+
output: {
|
| 74 |
+
manualChunks: {
|
| 75 |
+
'react-core': ['react', 'react-dom', 'react-router-dom'],
|
| 76 |
+
'semi-ui': ['@douyinfe/semi-icons', '@douyinfe/semi-ui'],
|
| 77 |
+
tools: ['axios', 'history', 'marked'],
|
| 78 |
+
'react-components': [
|
| 79 |
+
'react-dropzone',
|
| 80 |
+
'react-fireworks',
|
| 81 |
+
'react-telegram-login',
|
| 82 |
+
'react-toastify',
|
| 83 |
+
'react-turnstile',
|
| 84 |
+
],
|
| 85 |
+
i18n: [
|
| 86 |
+
'i18next',
|
| 87 |
+
'react-i18next',
|
| 88 |
+
'i18next-browser-languagedetector',
|
| 89 |
+
],
|
| 90 |
+
},
|
| 91 |
},
|
| 92 |
},
|
| 93 |
},
|
| 94 |
+
server: {
|
| 95 |
+
host: '0.0.0.0',
|
| 96 |
+
proxy: {
|
| 97 |
+
'/api': {
|
| 98 |
+
target: 'http://localhost:3000',
|
| 99 |
+
changeOrigin: true,
|
| 100 |
+
},
|
| 101 |
+
'/mj': {
|
| 102 |
+
target: 'http://localhost:3000',
|
| 103 |
+
changeOrigin: true,
|
| 104 |
+
},
|
| 105 |
+
'/pg': {
|
| 106 |
+
target: 'http://localhost:3000',
|
| 107 |
+
changeOrigin: true,
|
| 108 |
+
},
|
| 109 |
},
|
| 110 |
},
|
| 111 |
+
};
|
| 112 |
});
|