fix(build): fix environment variable configuration file failure

This commit is contained in:
vben
2020-12-22 22:13:03 +08:00
parent e6db0d39b9
commit bd7b53f14a
19 changed files with 158 additions and 245 deletions

View File

@@ -1,7 +1,6 @@
import { gzip } from 'zlib';
import { readFileSync, writeFileSync } from 'fs';
import { GzipPluginOptions } from './types';
import viteConfig from '../../../../vite.config';
import { readAllFile, getCwdPath, isBuildGzip, isSiteMode } from '../../../utils';
export function startGzip(
@@ -22,8 +21,8 @@ export function startGzip(
// 手动压缩css
export async function startGzipStyle() {
if (isBuildGzip() || isSiteMode()) {
const outDir = viteConfig.outDir || 'dist';
const assets = viteConfig.assetsDir || '_assets';
const outDir = 'dist';
const assets = '_assets';
const allCssFile = readAllFile(getCwdPath(outDir, assets), /\.(css)$/);
for (const path of allCssFile) {
const source = readFileSync(path);