提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
提示:以下是本篇文章正文内容,下面案例可供参考
一、根目录下vite.config.js。没有则创建之
import path from 'path';
import fs from 'fs-extra';
import { defineConfig } from 'vite';
import uni from '@dcloudio/vite-plugin-uni';
function copyFile() {
return {
enforce: 'post',
async writeBundle() {
var build_dir = path.join(__dirname, 'unpackage/dist/build');
var web_dir = path.join(build_dir, 'web');
console.log('打包', process.env.UNI_SCRIPT);
await fs.copy(
web_dir,
path.join(build_dir, process.env.UNI_SCRIPT)
);
await fs.copy(
path.join(web_dir, 'static'),
path.join(build_dir, process.env.UNI_SCRIPT, 'static')
);
},
};
}
export default defineConfig({
plugins: [uni(), copyFile()]
});