使用React js完成web前端
This commit is contained in:
1 parent
9e8c5f1ef0
commit
7600f0f9ed
130 files changed
+12708
-788
No files matched your search
@@ -0,0 +1,34 @@
|
||||
import { fileURLToPath, URL } from 'node:url';
|
||||
import react from '@vitejs/plugin-react';
|
||||
import { defineConfig } from 'vite';
|
||||
|
||||
// Vite 配置:React 插件、Monaco nonce 注入与构建输出。
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react(), {
|
||||
name: 'monaco-style-nonce',
|
||||
enforce: 'pre',
|
||||
transform(code, id) {
|
||||
if (!id.split('\\').join('/').includes('/monaco-editor/esm/')) return;
|
||||
const source = "document.createElement('style')";
|
||||
if (!code.includes(source)) return;
|
||||
return code.split(source).join(`Object.assign(document.createElement('style'), { nonce: document.querySelector('meta[name="chusql-style-nonce"]')?.content || '' })`);
|
||||
},
|
||||
}],
|
||||
base: '/static/',
|
||||
resolve: {
|
||||
alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) },
|
||||
},
|
||||
build: {
|
||||
outDir: '../static',
|
||||
emptyOutDir: true,
|
||||
assetsDir: '',
|
||||
rollupOptions: {
|
||||
output: {
|
||||
entryFileNames: 'app.js',
|
||||
chunkFileNames: '[name].js',
|
||||
assetFileNames: (asset) => asset.names?.some((name) => name.endsWith('.css')) ? 'style.css' : '[name][extname]',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in new issue
Block a user