unplugin-env 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-EQCBPN6Z.js → chunk-2KZLPXSE.js} +56 -43
- package/dist/{chunk-R5LAC3HA.js → chunk-5EP4GEYR.js} +1 -1
- package/dist/{chunk-CJQKBNAY.js → chunk-QAX3K5V3.js} +1 -1
- package/dist/esbuild.cjs +56 -43
- package/dist/esbuild.js +1 -1
- package/dist/index.cjs +56 -43
- package/dist/index.js +1 -1
- package/dist/nuxt.cjs +56 -43
- package/dist/nuxt.js +3 -3
- package/dist/rollup.cjs +56 -43
- package/dist/rollup.js +1 -1
- package/dist/types.d.cts +10 -3
- package/dist/types.d.ts +10 -3
- package/dist/vite.cjs +56 -43
- package/dist/vite.js +2 -2
- package/dist/webpack.cjs +56 -43
- package/dist/webpack.js +2 -2
- package/package.json +3 -2
|
@@ -562,7 +562,7 @@ var require_to_regex_range = __commonJS({
|
|
|
562
562
|
if (start === stop) {
|
|
563
563
|
return { pattern: start, count: [], digits: 0 };
|
|
564
564
|
}
|
|
565
|
-
let zipped =
|
|
565
|
+
let zipped = zip(start, stop);
|
|
566
566
|
let digits = zipped.length;
|
|
567
567
|
let pattern = "";
|
|
568
568
|
let count = 0;
|
|
@@ -622,7 +622,7 @@ var require_to_regex_range = __commonJS({
|
|
|
622
622
|
}
|
|
623
623
|
return result;
|
|
624
624
|
}
|
|
625
|
-
function
|
|
625
|
+
function zip(a, b) {
|
|
626
626
|
let arr = [];
|
|
627
627
|
for (let i = 0; i < a.length; i++)
|
|
628
628
|
arr.push([a[i], b[i]]);
|
|
@@ -3444,8 +3444,8 @@ var require_utils3 = __commonJS({
|
|
|
3444
3444
|
exports.array = array;
|
|
3445
3445
|
var errno = require_errno();
|
|
3446
3446
|
exports.errno = errno;
|
|
3447
|
-
var
|
|
3448
|
-
exports.fs =
|
|
3447
|
+
var fs4 = require_fs();
|
|
3448
|
+
exports.fs = fs4;
|
|
3449
3449
|
var path2 = require_path();
|
|
3450
3450
|
exports.path = path2;
|
|
3451
3451
|
var pattern = require_pattern();
|
|
@@ -3629,12 +3629,12 @@ var require_fs2 = __commonJS({
|
|
|
3629
3629
|
"use strict";
|
|
3630
3630
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3631
3631
|
exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
|
|
3632
|
-
var
|
|
3632
|
+
var fs4 = __require("fs");
|
|
3633
3633
|
exports.FILE_SYSTEM_ADAPTER = {
|
|
3634
|
-
lstat:
|
|
3635
|
-
stat:
|
|
3636
|
-
lstatSync:
|
|
3637
|
-
statSync:
|
|
3634
|
+
lstat: fs4.lstat,
|
|
3635
|
+
stat: fs4.stat,
|
|
3636
|
+
lstatSync: fs4.lstatSync,
|
|
3637
|
+
statSync: fs4.statSync
|
|
3638
3638
|
};
|
|
3639
3639
|
function createFileSystemAdapter(fsMethods) {
|
|
3640
3640
|
if (fsMethods === void 0) {
|
|
@@ -3651,12 +3651,12 @@ var require_settings = __commonJS({
|
|
|
3651
3651
|
"node_modules/.pnpm/@nodelib+fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/settings.js"(exports) {
|
|
3652
3652
|
"use strict";
|
|
3653
3653
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3654
|
-
var
|
|
3654
|
+
var fs4 = require_fs2();
|
|
3655
3655
|
var Settings = class {
|
|
3656
3656
|
constructor(_options = {}) {
|
|
3657
3657
|
this._options = _options;
|
|
3658
3658
|
this.followSymbolicLink = this._getValue(this._options.followSymbolicLink, true);
|
|
3659
|
-
this.fs =
|
|
3659
|
+
this.fs = fs4.createFileSystemAdapter(this._options.fs);
|
|
3660
3660
|
this.markSymbolicLink = this._getValue(this._options.markSymbolicLink, false);
|
|
3661
3661
|
this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
|
|
3662
3662
|
}
|
|
@@ -3816,8 +3816,8 @@ var require_utils4 = __commonJS({
|
|
|
3816
3816
|
"use strict";
|
|
3817
3817
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3818
3818
|
exports.fs = void 0;
|
|
3819
|
-
var
|
|
3820
|
-
exports.fs =
|
|
3819
|
+
var fs4 = require_fs3();
|
|
3820
|
+
exports.fs = fs4;
|
|
3821
3821
|
}
|
|
3822
3822
|
});
|
|
3823
3823
|
|
|
@@ -4012,14 +4012,14 @@ var require_fs4 = __commonJS({
|
|
|
4012
4012
|
"use strict";
|
|
4013
4013
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4014
4014
|
exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
|
|
4015
|
-
var
|
|
4015
|
+
var fs4 = __require("fs");
|
|
4016
4016
|
exports.FILE_SYSTEM_ADAPTER = {
|
|
4017
|
-
lstat:
|
|
4018
|
-
stat:
|
|
4019
|
-
lstatSync:
|
|
4020
|
-
statSync:
|
|
4021
|
-
readdir:
|
|
4022
|
-
readdirSync:
|
|
4017
|
+
lstat: fs4.lstat,
|
|
4018
|
+
stat: fs4.stat,
|
|
4019
|
+
lstatSync: fs4.lstatSync,
|
|
4020
|
+
statSync: fs4.statSync,
|
|
4021
|
+
readdir: fs4.readdir,
|
|
4022
|
+
readdirSync: fs4.readdirSync
|
|
4023
4023
|
};
|
|
4024
4024
|
function createFileSystemAdapter(fsMethods) {
|
|
4025
4025
|
if (fsMethods === void 0) {
|
|
@@ -4038,12 +4038,12 @@ var require_settings2 = __commonJS({
|
|
|
4038
4038
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4039
4039
|
var path2 = __require("path");
|
|
4040
4040
|
var fsStat = require_out();
|
|
4041
|
-
var
|
|
4041
|
+
var fs4 = require_fs4();
|
|
4042
4042
|
var Settings = class {
|
|
4043
4043
|
constructor(_options = {}) {
|
|
4044
4044
|
this._options = _options;
|
|
4045
4045
|
this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false);
|
|
4046
|
-
this.fs =
|
|
4046
|
+
this.fs = fs4.createFileSystemAdapter(this._options.fs);
|
|
4047
4047
|
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path2.sep);
|
|
4048
4048
|
this.stats = this._getValue(this._options.stats, false);
|
|
4049
4049
|
this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
|
|
@@ -5379,16 +5379,16 @@ var require_settings4 = __commonJS({
|
|
|
5379
5379
|
"use strict";
|
|
5380
5380
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5381
5381
|
exports.DEFAULT_FILE_SYSTEM_ADAPTER = void 0;
|
|
5382
|
-
var
|
|
5382
|
+
var fs4 = __require("fs");
|
|
5383
5383
|
var os2 = __require("os");
|
|
5384
5384
|
var CPU_COUNT = Math.max(os2.cpus().length, 1);
|
|
5385
5385
|
exports.DEFAULT_FILE_SYSTEM_ADAPTER = {
|
|
5386
|
-
lstat:
|
|
5387
|
-
lstatSync:
|
|
5388
|
-
stat:
|
|
5389
|
-
statSync:
|
|
5390
|
-
readdir:
|
|
5391
|
-
readdirSync:
|
|
5386
|
+
lstat: fs4.lstat,
|
|
5387
|
+
lstatSync: fs4.lstatSync,
|
|
5388
|
+
stat: fs4.stat,
|
|
5389
|
+
statSync: fs4.statSync,
|
|
5390
|
+
readdir: fs4.readdir,
|
|
5391
|
+
readdirSync: fs4.readdirSync
|
|
5392
5392
|
};
|
|
5393
5393
|
var Settings = class {
|
|
5394
5394
|
constructor(_options = {}) {
|
|
@@ -21586,7 +21586,7 @@ var require_lib = __commonJS({
|
|
|
21586
21586
|
});
|
|
21587
21587
|
|
|
21588
21588
|
// src/index.ts
|
|
21589
|
-
import { promises as
|
|
21589
|
+
import { promises as fs3 } from "node:fs";
|
|
21590
21590
|
import process5 from "node:process";
|
|
21591
21591
|
import { createUnplugin } from "unplugin";
|
|
21592
21592
|
|
|
@@ -30343,7 +30343,7 @@ async function loadFile(filename, options = {}) {
|
|
|
30343
30343
|
import { deepMerge } from "@antfu/utils";
|
|
30344
30344
|
async function generateScript(options, mode) {
|
|
30345
30345
|
const { dir, fileName, globalName, serve, build } = options.env;
|
|
30346
|
-
const folder = await findFolder(process2.cwd(), dir
|
|
30346
|
+
const folder = await findFolder(process2.cwd(), dir);
|
|
30347
30347
|
const files = await (0, import_fast_glob.default)("*.+(js|ts)", {
|
|
30348
30348
|
absolute: true,
|
|
30349
30349
|
cwd: folder
|
|
@@ -30352,7 +30352,7 @@ async function generateScript(options, mode) {
|
|
|
30352
30352
|
let target = {};
|
|
30353
30353
|
const source = [];
|
|
30354
30354
|
let code = "";
|
|
30355
|
-
const name = fileName
|
|
30355
|
+
const name = fileName;
|
|
30356
30356
|
for (const file of files) {
|
|
30357
30357
|
try {
|
|
30358
30358
|
const mod = await loadFile(file);
|
|
@@ -30412,7 +30412,7 @@ async function findFolder(directoryPath, dir) {
|
|
|
30412
30412
|
|
|
30413
30413
|
// src/core/options.ts
|
|
30414
30414
|
import { deepMerge as deepMerge2 } from "@antfu/utils";
|
|
30415
|
-
|
|
30415
|
+
function resolveOptions(options) {
|
|
30416
30416
|
const defaults2 = {
|
|
30417
30417
|
env: {
|
|
30418
30418
|
dir: "config",
|
|
@@ -30420,6 +30420,10 @@ async function resolveOptions(options) {
|
|
|
30420
30420
|
globalName: "manifest",
|
|
30421
30421
|
serve: /dev|development/i,
|
|
30422
30422
|
build: /prod|production/i
|
|
30423
|
+
},
|
|
30424
|
+
compress: {
|
|
30425
|
+
outDir: "dist",
|
|
30426
|
+
ignoreBase: true
|
|
30423
30427
|
}
|
|
30424
30428
|
};
|
|
30425
30429
|
const mergeOptions = deepMerge2(defaults2, options);
|
|
@@ -30430,8 +30434,9 @@ async function resolveOptions(options) {
|
|
|
30430
30434
|
}
|
|
30431
30435
|
|
|
30432
30436
|
// src/core/compress.ts
|
|
30437
|
+
import fs2 from "node:fs";
|
|
30433
30438
|
import process4 from "node:process";
|
|
30434
|
-
import
|
|
30439
|
+
import archiver from "archiver";
|
|
30435
30440
|
|
|
30436
30441
|
// node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
30437
30442
|
var ANSI_BACKGROUND_OFFSET = 10;
|
|
@@ -30938,10 +30943,19 @@ var Log = class {
|
|
|
30938
30943
|
|
|
30939
30944
|
// src/core/compress.ts
|
|
30940
30945
|
async function createCompress(options) {
|
|
30941
|
-
|
|
30946
|
+
const { outDir, ignoreBase } = options;
|
|
30947
|
+
const zipFilePath = `${outDir}.zip`;
|
|
30948
|
+
Log.log("Compressing the directory", outDir);
|
|
30942
30949
|
try {
|
|
30943
|
-
|
|
30944
|
-
|
|
30950
|
+
const output = fs2.createWriteStream(zipFilePath);
|
|
30951
|
+
const archive = archiver("zip", {
|
|
30952
|
+
zlib: { level: 9 }
|
|
30953
|
+
// 设置压缩级别为最高
|
|
30954
|
+
});
|
|
30955
|
+
archive.pipe(output);
|
|
30956
|
+
archive.directory(outDir, ignoreBase ? outDir : false);
|
|
30957
|
+
await archive.finalize();
|
|
30958
|
+
Log.success("Successfully compressed the directory", outDir);
|
|
30945
30959
|
process4.exit(0);
|
|
30946
30960
|
} catch (error) {
|
|
30947
30961
|
Log.error("Error compressing the directory", error);
|
|
@@ -30964,8 +30978,7 @@ var unpluginFactory = (options = {}) => {
|
|
|
30964
30978
|
},
|
|
30965
30979
|
async load(id) {
|
|
30966
30980
|
if (id.startsWith(resolvedVirtualEnvId)) {
|
|
30967
|
-
const
|
|
30968
|
-
const { code, watchFiles } = await generateScript(config, "serve");
|
|
30981
|
+
const { code, watchFiles } = await generateScript(resolved, "serve");
|
|
30969
30982
|
watchFiles.forEach((file) => {
|
|
30970
30983
|
this.addWatchFile(file);
|
|
30971
30984
|
});
|
|
@@ -30981,14 +30994,13 @@ var unpluginFactory = (options = {}) => {
|
|
|
30981
30994
|
return resolvedVirtualEnvId;
|
|
30982
30995
|
},
|
|
30983
30996
|
async load(id) {
|
|
30984
|
-
const
|
|
30985
|
-
const { emit, script } = await generateScript(config, "build");
|
|
30997
|
+
const { emit, script } = await generateScript(resolved, "build");
|
|
30986
30998
|
if (id.startsWith(resolvedVirtualEnvId)) {
|
|
30987
30999
|
this.emitFile(emit);
|
|
30988
31000
|
return "";
|
|
30989
31001
|
}
|
|
30990
31002
|
if (id.endsWith(".html")) {
|
|
30991
|
-
let code = await
|
|
31003
|
+
let code = await fs3.readFile(id, "utf8");
|
|
30992
31004
|
code = code.replace(/<\/head>/gm, script);
|
|
30993
31005
|
return {
|
|
30994
31006
|
code
|
|
@@ -30998,7 +31010,8 @@ var unpluginFactory = (options = {}) => {
|
|
|
30998
31010
|
},
|
|
30999
31011
|
buildEnd: () => {
|
|
31000
31012
|
process5.on("beforeExit", async () => {
|
|
31001
|
-
|
|
31013
|
+
const { compress } = resolved;
|
|
31014
|
+
await createCompress(compress);
|
|
31002
31015
|
});
|
|
31003
31016
|
}
|
|
31004
31017
|
}];
|
package/dist/esbuild.cjs
CHANGED
|
@@ -561,7 +561,7 @@ var require_to_regex_range = __commonJS({
|
|
|
561
561
|
if (start === stop) {
|
|
562
562
|
return { pattern: start, count: [], digits: 0 };
|
|
563
563
|
}
|
|
564
|
-
let zipped =
|
|
564
|
+
let zipped = zip(start, stop);
|
|
565
565
|
let digits = zipped.length;
|
|
566
566
|
let pattern = "";
|
|
567
567
|
let count = 0;
|
|
@@ -621,7 +621,7 @@ var require_to_regex_range = __commonJS({
|
|
|
621
621
|
}
|
|
622
622
|
return result;
|
|
623
623
|
}
|
|
624
|
-
function
|
|
624
|
+
function zip(a, b) {
|
|
625
625
|
let arr = [];
|
|
626
626
|
for (let i = 0; i < a.length; i++)
|
|
627
627
|
arr.push([a[i], b[i]]);
|
|
@@ -3443,8 +3443,8 @@ var require_utils3 = __commonJS({
|
|
|
3443
3443
|
exports2.array = array;
|
|
3444
3444
|
var errno = require_errno();
|
|
3445
3445
|
exports2.errno = errno;
|
|
3446
|
-
var
|
|
3447
|
-
exports2.fs =
|
|
3446
|
+
var fs4 = require_fs();
|
|
3447
|
+
exports2.fs = fs4;
|
|
3448
3448
|
var path2 = require_path();
|
|
3449
3449
|
exports2.path = path2;
|
|
3450
3450
|
var pattern = require_pattern();
|
|
@@ -3628,12 +3628,12 @@ var require_fs2 = __commonJS({
|
|
|
3628
3628
|
"use strict";
|
|
3629
3629
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
3630
3630
|
exports2.createFileSystemAdapter = exports2.FILE_SYSTEM_ADAPTER = void 0;
|
|
3631
|
-
var
|
|
3631
|
+
var fs4 = require("fs");
|
|
3632
3632
|
exports2.FILE_SYSTEM_ADAPTER = {
|
|
3633
|
-
lstat:
|
|
3634
|
-
stat:
|
|
3635
|
-
lstatSync:
|
|
3636
|
-
statSync:
|
|
3633
|
+
lstat: fs4.lstat,
|
|
3634
|
+
stat: fs4.stat,
|
|
3635
|
+
lstatSync: fs4.lstatSync,
|
|
3636
|
+
statSync: fs4.statSync
|
|
3637
3637
|
};
|
|
3638
3638
|
function createFileSystemAdapter(fsMethods) {
|
|
3639
3639
|
if (fsMethods === void 0) {
|
|
@@ -3650,12 +3650,12 @@ var require_settings = __commonJS({
|
|
|
3650
3650
|
"node_modules/.pnpm/@nodelib+fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/settings.js"(exports2) {
|
|
3651
3651
|
"use strict";
|
|
3652
3652
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
3653
|
-
var
|
|
3653
|
+
var fs4 = require_fs2();
|
|
3654
3654
|
var Settings = class {
|
|
3655
3655
|
constructor(_options = {}) {
|
|
3656
3656
|
this._options = _options;
|
|
3657
3657
|
this.followSymbolicLink = this._getValue(this._options.followSymbolicLink, true);
|
|
3658
|
-
this.fs =
|
|
3658
|
+
this.fs = fs4.createFileSystemAdapter(this._options.fs);
|
|
3659
3659
|
this.markSymbolicLink = this._getValue(this._options.markSymbolicLink, false);
|
|
3660
3660
|
this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
|
|
3661
3661
|
}
|
|
@@ -3815,8 +3815,8 @@ var require_utils4 = __commonJS({
|
|
|
3815
3815
|
"use strict";
|
|
3816
3816
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
3817
3817
|
exports2.fs = void 0;
|
|
3818
|
-
var
|
|
3819
|
-
exports2.fs =
|
|
3818
|
+
var fs4 = require_fs3();
|
|
3819
|
+
exports2.fs = fs4;
|
|
3820
3820
|
}
|
|
3821
3821
|
});
|
|
3822
3822
|
|
|
@@ -4011,14 +4011,14 @@ var require_fs4 = __commonJS({
|
|
|
4011
4011
|
"use strict";
|
|
4012
4012
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
4013
4013
|
exports2.createFileSystemAdapter = exports2.FILE_SYSTEM_ADAPTER = void 0;
|
|
4014
|
-
var
|
|
4014
|
+
var fs4 = require("fs");
|
|
4015
4015
|
exports2.FILE_SYSTEM_ADAPTER = {
|
|
4016
|
-
lstat:
|
|
4017
|
-
stat:
|
|
4018
|
-
lstatSync:
|
|
4019
|
-
statSync:
|
|
4020
|
-
readdir:
|
|
4021
|
-
readdirSync:
|
|
4016
|
+
lstat: fs4.lstat,
|
|
4017
|
+
stat: fs4.stat,
|
|
4018
|
+
lstatSync: fs4.lstatSync,
|
|
4019
|
+
statSync: fs4.statSync,
|
|
4020
|
+
readdir: fs4.readdir,
|
|
4021
|
+
readdirSync: fs4.readdirSync
|
|
4022
4022
|
};
|
|
4023
4023
|
function createFileSystemAdapter(fsMethods) {
|
|
4024
4024
|
if (fsMethods === void 0) {
|
|
@@ -4037,12 +4037,12 @@ var require_settings2 = __commonJS({
|
|
|
4037
4037
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
4038
4038
|
var path2 = require("path");
|
|
4039
4039
|
var fsStat = require_out();
|
|
4040
|
-
var
|
|
4040
|
+
var fs4 = require_fs4();
|
|
4041
4041
|
var Settings = class {
|
|
4042
4042
|
constructor(_options = {}) {
|
|
4043
4043
|
this._options = _options;
|
|
4044
4044
|
this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false);
|
|
4045
|
-
this.fs =
|
|
4045
|
+
this.fs = fs4.createFileSystemAdapter(this._options.fs);
|
|
4046
4046
|
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path2.sep);
|
|
4047
4047
|
this.stats = this._getValue(this._options.stats, false);
|
|
4048
4048
|
this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
|
|
@@ -5378,16 +5378,16 @@ var require_settings4 = __commonJS({
|
|
|
5378
5378
|
"use strict";
|
|
5379
5379
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
5380
5380
|
exports2.DEFAULT_FILE_SYSTEM_ADAPTER = void 0;
|
|
5381
|
-
var
|
|
5381
|
+
var fs4 = require("fs");
|
|
5382
5382
|
var os2 = require("os");
|
|
5383
5383
|
var CPU_COUNT = Math.max(os2.cpus().length, 1);
|
|
5384
5384
|
exports2.DEFAULT_FILE_SYSTEM_ADAPTER = {
|
|
5385
|
-
lstat:
|
|
5386
|
-
lstatSync:
|
|
5387
|
-
stat:
|
|
5388
|
-
statSync:
|
|
5389
|
-
readdir:
|
|
5390
|
-
readdirSync:
|
|
5385
|
+
lstat: fs4.lstat,
|
|
5386
|
+
lstatSync: fs4.lstatSync,
|
|
5387
|
+
stat: fs4.stat,
|
|
5388
|
+
statSync: fs4.statSync,
|
|
5389
|
+
readdir: fs4.readdir,
|
|
5390
|
+
readdirSync: fs4.readdirSync
|
|
5391
5391
|
};
|
|
5392
5392
|
var Settings = class {
|
|
5393
5393
|
constructor(_options = {}) {
|
|
@@ -21593,7 +21593,7 @@ module.exports = __toCommonJS(esbuild_exports);
|
|
|
21593
21593
|
var import_unplugin2 = require("unplugin");
|
|
21594
21594
|
|
|
21595
21595
|
// src/index.ts
|
|
21596
|
-
var
|
|
21596
|
+
var import_node_fs4 = require("fs");
|
|
21597
21597
|
var import_node_process4 = __toESM(require("process"), 1);
|
|
21598
21598
|
var import_unplugin = require("unplugin");
|
|
21599
21599
|
|
|
@@ -30350,7 +30350,7 @@ async function loadFile(filename, options = {}) {
|
|
|
30350
30350
|
var import_utils = require("@antfu/utils");
|
|
30351
30351
|
async function generateScript(options, mode) {
|
|
30352
30352
|
const { dir, fileName, globalName, serve, build } = options.env;
|
|
30353
|
-
const folder = await findFolder(import_node_process.default.cwd(), dir
|
|
30353
|
+
const folder = await findFolder(import_node_process.default.cwd(), dir);
|
|
30354
30354
|
const files = await (0, import_fast_glob.default)("*.+(js|ts)", {
|
|
30355
30355
|
absolute: true,
|
|
30356
30356
|
cwd: folder
|
|
@@ -30359,7 +30359,7 @@ async function generateScript(options, mode) {
|
|
|
30359
30359
|
let target = {};
|
|
30360
30360
|
const source = [];
|
|
30361
30361
|
let code = "";
|
|
30362
|
-
const name = fileName
|
|
30362
|
+
const name = fileName;
|
|
30363
30363
|
for (const file of files) {
|
|
30364
30364
|
try {
|
|
30365
30365
|
const mod = await loadFile(file);
|
|
@@ -30419,7 +30419,7 @@ async function findFolder(directoryPath, dir) {
|
|
|
30419
30419
|
|
|
30420
30420
|
// src/core/options.ts
|
|
30421
30421
|
var import_utils2 = require("@antfu/utils");
|
|
30422
|
-
|
|
30422
|
+
function resolveOptions(options) {
|
|
30423
30423
|
const defaults2 = {
|
|
30424
30424
|
env: {
|
|
30425
30425
|
dir: "config",
|
|
@@ -30427,6 +30427,10 @@ async function resolveOptions(options) {
|
|
|
30427
30427
|
globalName: "manifest",
|
|
30428
30428
|
serve: /dev|development/i,
|
|
30429
30429
|
build: /prod|production/i
|
|
30430
|
+
},
|
|
30431
|
+
compress: {
|
|
30432
|
+
outDir: "dist",
|
|
30433
|
+
ignoreBase: true
|
|
30430
30434
|
}
|
|
30431
30435
|
};
|
|
30432
30436
|
const mergeOptions = (0, import_utils2.deepMerge)(defaults2, options);
|
|
@@ -30437,8 +30441,9 @@ async function resolveOptions(options) {
|
|
|
30437
30441
|
}
|
|
30438
30442
|
|
|
30439
30443
|
// src/core/compress.ts
|
|
30444
|
+
var import_node_fs3 = __toESM(require("fs"), 1);
|
|
30440
30445
|
var import_node_process3 = __toESM(require("process"), 1);
|
|
30441
|
-
var
|
|
30446
|
+
var import_archiver = __toESM(require("archiver"), 1);
|
|
30442
30447
|
|
|
30443
30448
|
// node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
30444
30449
|
var ANSI_BACKGROUND_OFFSET = 10;
|
|
@@ -30945,10 +30950,19 @@ var Log = class {
|
|
|
30945
30950
|
|
|
30946
30951
|
// src/core/compress.ts
|
|
30947
30952
|
async function createCompress(options) {
|
|
30948
|
-
|
|
30953
|
+
const { outDir, ignoreBase } = options;
|
|
30954
|
+
const zipFilePath = `${outDir}.zip`;
|
|
30955
|
+
Log.log("Compressing the directory", outDir);
|
|
30949
30956
|
try {
|
|
30950
|
-
|
|
30951
|
-
|
|
30957
|
+
const output = import_node_fs3.default.createWriteStream(zipFilePath);
|
|
30958
|
+
const archive = (0, import_archiver.default)("zip", {
|
|
30959
|
+
zlib: { level: 9 }
|
|
30960
|
+
// 设置压缩级别为最高
|
|
30961
|
+
});
|
|
30962
|
+
archive.pipe(output);
|
|
30963
|
+
archive.directory(outDir, ignoreBase ? outDir : false);
|
|
30964
|
+
await archive.finalize();
|
|
30965
|
+
Log.success("Successfully compressed the directory", outDir);
|
|
30952
30966
|
import_node_process3.default.exit(0);
|
|
30953
30967
|
} catch (error) {
|
|
30954
30968
|
Log.error("Error compressing the directory", error);
|
|
@@ -30971,8 +30985,7 @@ var unpluginFactory = (options = {}) => {
|
|
|
30971
30985
|
},
|
|
30972
30986
|
async load(id) {
|
|
30973
30987
|
if (id.startsWith(resolvedVirtualEnvId)) {
|
|
30974
|
-
const
|
|
30975
|
-
const { code, watchFiles } = await generateScript(config, "serve");
|
|
30988
|
+
const { code, watchFiles } = await generateScript(resolved, "serve");
|
|
30976
30989
|
watchFiles.forEach((file) => {
|
|
30977
30990
|
this.addWatchFile(file);
|
|
30978
30991
|
});
|
|
@@ -30988,14 +31001,13 @@ var unpluginFactory = (options = {}) => {
|
|
|
30988
31001
|
return resolvedVirtualEnvId;
|
|
30989
31002
|
},
|
|
30990
31003
|
async load(id) {
|
|
30991
|
-
const
|
|
30992
|
-
const { emit, script } = await generateScript(config, "build");
|
|
31004
|
+
const { emit, script } = await generateScript(resolved, "build");
|
|
30993
31005
|
if (id.startsWith(resolvedVirtualEnvId)) {
|
|
30994
31006
|
this.emitFile(emit);
|
|
30995
31007
|
return "";
|
|
30996
31008
|
}
|
|
30997
31009
|
if (id.endsWith(".html")) {
|
|
30998
|
-
let code = await
|
|
31010
|
+
let code = await import_node_fs4.promises.readFile(id, "utf8");
|
|
30999
31011
|
code = code.replace(/<\/head>/gm, script);
|
|
31000
31012
|
return {
|
|
31001
31013
|
code
|
|
@@ -31005,7 +31017,8 @@ var unpluginFactory = (options = {}) => {
|
|
|
31005
31017
|
},
|
|
31006
31018
|
buildEnd: () => {
|
|
31007
31019
|
import_node_process4.default.on("beforeExit", async () => {
|
|
31008
|
-
|
|
31020
|
+
const { compress } = resolved;
|
|
31021
|
+
await createCompress(compress);
|
|
31009
31022
|
});
|
|
31010
31023
|
}
|
|
31011
31024
|
}];
|