From 94149161b3c4a59538f5ec90938d6b2cd7b8b82e Mon Sep 17 00:00:00 2001 From: 1638245306 <1638245306@qq.com> Date: Wed, 30 Apr 2025 12:55:58 +0800 Subject: [PATCH] =?UTF-8?q?build(flowH5):=20=E6=B7=BB=E5=8A=A0=20flowH5=20?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=9A=84=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 flowH5.config.ts 文件,配置 Vite 构建项目- 设置 Vue 插件和路径别名 - 配置 Roll --- web/flowH5.config.ts | 77 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 web/flowH5.config.ts diff --git a/web/flowH5.config.ts b/web/flowH5.config.ts new file mode 100644 index 0000000..21fbac9 --- /dev/null +++ b/web/flowH5.config.ts @@ -0,0 +1,77 @@ +import { defineConfig } from 'vite'; +import vue from '@vitejs/plugin-vue'; +import path, {resolve} from 'path'; +import vueJsx from "@vitejs/plugin-vue-jsx"; +import vueSetupExtend from "vite-plugin-vue-setup-extend"; +import { terser } from 'rollup-plugin-terser'; +import postcss from 'rollup-plugin-postcss'; +import pxtorem from 'postcss-pxtorem'; +const pathResolve = (dir: string) => { + return resolve(__dirname, '.', dir); +}; +export default defineConfig({ + build: { + // outDir: '../backend/static/previewer', + lib: { + entry: path.resolve(__dirname, './index.ts'), // 库的入口文件 + name: 'previewer', // 库的全局变量名称 + fileName: (format) => `index.${format}.js`, // 输出文件名格式 + }, + rollupOptions: { + input:{ + previewer: path.resolve(__dirname, './index.ts'), + }, + external: ['vue'], // 指定外部依赖 + output:{ + // dir: '../backend/static/previewer', // 输出目录 + entryFileNames: 'index.[format].js', // 入口文件名格式 + format: 'commonjs', + globals: { + vue: 'Vue' + }, + chunkFileNames: `[name].[hash].js` + }, + plugins: [ + terser({ + compress: { + drop_console: false, // 确保不移除 console.log + }, + }), + postcss({ + plugins: [ + pxtorem({ + rootValue: 37.5, + unitPrecision: 5, + propList: ['*'], + selectorBlackList: [], + replace: true, + mediaQuery: false, + minPixelValue: 0, + exclude: /node_modules/i, + }), + ], + }), + ], + }, + }, + plugins: [ + vue(), + vueJsx(), + vueSetupExtend(), + ], + resolve: { + alias: { + '/@': path.resolve(__dirname, 'src'), // '@' 别名指向 'src' 目录 + '@views': pathResolve('./src/views'), + '/src':path.resolve(__dirname, 'src') + }, + }, + css:{ + postcss:{ + + } + }, + define: { + 'process.env': {} + } +}); \ No newline at end of file