import { fileURLToPath, URL } from 'node:url'; import copy from 'rollup-plugin-copy'; import { defineConfig } from 'vite'; import vue from '@vitejs/plugin-vue'; import { createHtmlPlugin } from 'vite-plugin-html'; // https://vitejs.dev/config/ export default defineConfig({ // server: { // proxy: { // '/my-report/assets/imgs/': { // target: `http://${host}:${port}/`, // rewrite: (path) => path.replace('assets', 'src/assets'), // }, // }, // }, plugins: [ vue(), copy({ // https://www.npmjs.com/package/rollup-plugin-copy targets: [ { src: 'node_modules/bosgeo-ui/dist/Assets', dest: 'dist/lib' }, { src: 'node_modules/bosgeo-ui/dist/ThirdParty', dest: 'dist/lib' }, { src: 'node_modules/bosgeo-ui/dist/Widgets', dest: 'dist/lib' }, { src: 'node_modules/bosgeo-ui/dist/Workers', dest: 'dist/lib' }, ], hook: 'writeBundle', }), createHtmlPlugin({ template: 'index.html', minify: true, inject: { data: { htmlWebpackPlugin: { options: { key: 'value', // 在 html 中添加数据 }, }, }, }, }), ], resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)), }, }, }); // vite 注意事项:https://blog.csdn.net/tonylua/article/details/123391231