初始化
缺陷:主题配色需要优化整体的同风格
This commit is contained in:
@@ -4,22 +4,30 @@ import type { ArchiverPluginOptions } from '../typing';
|
||||
|
||||
import fs from 'node:fs';
|
||||
import fsp from 'node:fs/promises';
|
||||
import { join } from 'node:path';
|
||||
import { basename, isAbsolute, join } from 'node:path';
|
||||
|
||||
import { ZipArchive } from 'archiver';
|
||||
|
||||
export const viteArchiverPlugin = (
|
||||
options: ArchiverPluginOptions = {},
|
||||
): PluginOption => {
|
||||
// 归档必须跟随实际构建目录,否则 --outDir dist-brm 这类多产物构建会去压缩上一次的 dist
|
||||
let resolvedOutDir = 'dist';
|
||||
|
||||
return {
|
||||
apply: 'build',
|
||||
configResolved(config) {
|
||||
resolvedOutDir = config.build.outDir || 'dist';
|
||||
},
|
||||
closeBundle: {
|
||||
handler() {
|
||||
const { name = 'dist', outputDir = '.' } = options;
|
||||
const { outputDir = '.' } = options;
|
||||
const folderToZip = isAbsolute(resolvedOutDir)
|
||||
? resolvedOutDir
|
||||
: join(process.cwd(), resolvedOutDir);
|
||||
const name = options.name ?? basename(folderToZip);
|
||||
|
||||
setTimeout(async () => {
|
||||
const folderToZip = 'dist';
|
||||
|
||||
const zipOutputDir = join(process.cwd(), outputDir);
|
||||
const zipOutputPath = join(zipOutputDir, `${name}.zip`);
|
||||
try {
|
||||
|
||||
@@ -85,7 +85,7 @@ interface NitroMockPluginOptions {
|
||||
interface ArchiverPluginOptions {
|
||||
/**
|
||||
* 输出文件名
|
||||
* @default 'dist'
|
||||
* @default 构建目录名(build.outDir)
|
||||
*/
|
||||
name?: string;
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user