|
|
@@ -0,0 +1,41 @@
|
|
|
+import {
|
|
|
+ defineConfig
|
|
|
+} from 'vite';
|
|
|
+import uni from '@dcloudio/vite-plugin-uni';
|
|
|
+import path from "path";
|
|
|
+
|
|
|
+// import fs from 'fs-extra'
|
|
|
+
|
|
|
+let filePath = ''
|
|
|
+let Timestamp = ''
|
|
|
+
|
|
|
+//编译环境判断,判断是否H5环境
|
|
|
+if (process.env.UNI_PLATFORM === 'h5') {
|
|
|
+ filePath = 'assets/'; //打包文件存放文件夹路径
|
|
|
+ Timestamp = '.' + new Date().getTime(); //时间戳
|
|
|
+}
|
|
|
+
|
|
|
+export default defineConfig({
|
|
|
+ resolve: {
|
|
|
+ alias: {
|
|
|
+ "@": path.resolve(__dirname, "./src")
|
|
|
+ },
|
|
|
+ },
|
|
|
+ // 需要用到的插件数组
|
|
|
+ plugins: [
|
|
|
+ uni()
|
|
|
+ ],
|
|
|
+ build: {
|
|
|
+ rollupOptions: {
|
|
|
+ output: {
|
|
|
+ // 输出重构 打包编译后的 文件目录 文件名称 【模块名称.时间戳】
|
|
|
+ // 入口文件名
|
|
|
+ entryFileNames: `${filePath}[name]${Timestamp}.js`,
|
|
|
+ // 块文件名
|
|
|
+ chunkFileNames: `${filePath}[name]${Timestamp}.js`,
|
|
|
+ // 资源文件名 css 图片等等
|
|
|
+ assetFileNames: `${filePath}[name]${Timestamp}.[ext]`
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+});
|