unplugin-env 1.0.0 → 1.0.2
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/LICENSE +1 -1
- package/README.md +68 -2
- package/README.zh-CN.md +236 -0
- package/dist/{chunk-OQXUTP45.js → chunk-664Z6SFJ.js} +1 -1
- package/dist/{chunk-JDYYGKOJ.js → chunk-6I6MSMXF.js} +1 -1
- package/dist/{chunk-U7BMFDAG.js → chunk-V2T5VQQ7.js} +153 -148
- package/dist/esbuild.cjs +153 -148
- package/dist/esbuild.js +1 -1
- package/dist/index.cjs +153 -148
- package/dist/index.js +1 -1
- package/dist/nuxt.cjs +154 -149
- package/dist/nuxt.js +4 -4
- package/dist/rollup.cjs +153 -148
- package/dist/rollup.js +1 -1
- package/dist/types.d.cts +1 -2
- package/dist/types.d.ts +1 -2
- package/dist/vite.cjs +153 -148
- package/dist/vite.js +2 -2
- package/dist/webpack.cjs +153 -148
- package/dist/webpack.js +2 -2
- package/package.json +31 -23
package/dist/index.cjs
CHANGED
|
@@ -4309,41 +4309,41 @@ var require_queue = __commonJS({
|
|
|
4309
4309
|
queue.drained = drained;
|
|
4310
4310
|
return queue;
|
|
4311
4311
|
function push(value) {
|
|
4312
|
-
var p = new Promise(function(
|
|
4312
|
+
var p = new Promise(function(resolve, reject) {
|
|
4313
4313
|
pushCb(value, function(err, result) {
|
|
4314
4314
|
if (err) {
|
|
4315
4315
|
reject(err);
|
|
4316
4316
|
return;
|
|
4317
4317
|
}
|
|
4318
|
-
|
|
4318
|
+
resolve(result);
|
|
4319
4319
|
});
|
|
4320
4320
|
});
|
|
4321
4321
|
p.catch(noop);
|
|
4322
4322
|
return p;
|
|
4323
4323
|
}
|
|
4324
4324
|
function unshift(value) {
|
|
4325
|
-
var p = new Promise(function(
|
|
4325
|
+
var p = new Promise(function(resolve, reject) {
|
|
4326
4326
|
unshiftCb(value, function(err, result) {
|
|
4327
4327
|
if (err) {
|
|
4328
4328
|
reject(err);
|
|
4329
4329
|
return;
|
|
4330
4330
|
}
|
|
4331
|
-
|
|
4331
|
+
resolve(result);
|
|
4332
4332
|
});
|
|
4333
4333
|
});
|
|
4334
4334
|
p.catch(noop);
|
|
4335
4335
|
return p;
|
|
4336
4336
|
}
|
|
4337
4337
|
function drained() {
|
|
4338
|
-
var p = new Promise(function(
|
|
4338
|
+
var p = new Promise(function(resolve) {
|
|
4339
4339
|
process.nextTick(function() {
|
|
4340
4340
|
if (queue.idle()) {
|
|
4341
|
-
|
|
4341
|
+
resolve();
|
|
4342
4342
|
} else {
|
|
4343
4343
|
var previousDrain = queue.drain;
|
|
4344
4344
|
queue.drain = function() {
|
|
4345
4345
|
if (typeof previousDrain === "function") previousDrain();
|
|
4346
|
-
|
|
4346
|
+
resolve();
|
|
4347
4347
|
queue.drain = previousDrain;
|
|
4348
4348
|
};
|
|
4349
4349
|
}
|
|
@@ -4829,9 +4829,9 @@ var require_stream3 = __commonJS({
|
|
|
4829
4829
|
});
|
|
4830
4830
|
}
|
|
4831
4831
|
_getStat(filepath) {
|
|
4832
|
-
return new Promise((
|
|
4832
|
+
return new Promise((resolve, reject) => {
|
|
4833
4833
|
this._stat(filepath, this._fsStatSettings, (error, stats) => {
|
|
4834
|
-
return error === null ?
|
|
4834
|
+
return error === null ? resolve(stats) : reject(error);
|
|
4835
4835
|
});
|
|
4836
4836
|
});
|
|
4837
4837
|
}
|
|
@@ -4855,10 +4855,10 @@ var require_async5 = __commonJS({
|
|
|
4855
4855
|
this._readerStream = new stream_1.default(this._settings);
|
|
4856
4856
|
}
|
|
4857
4857
|
dynamic(root, options) {
|
|
4858
|
-
return new Promise((
|
|
4858
|
+
return new Promise((resolve, reject) => {
|
|
4859
4859
|
this._walkAsync(root, options, (error, entries) => {
|
|
4860
4860
|
if (error === null) {
|
|
4861
|
-
|
|
4861
|
+
resolve(entries);
|
|
4862
4862
|
} else {
|
|
4863
4863
|
reject(error);
|
|
4864
4864
|
}
|
|
@@ -4868,10 +4868,10 @@ var require_async5 = __commonJS({
|
|
|
4868
4868
|
async static(patterns, options) {
|
|
4869
4869
|
const entries = [];
|
|
4870
4870
|
const stream = this._readerStream.static(patterns, options);
|
|
4871
|
-
return new Promise((
|
|
4871
|
+
return new Promise((resolve, reject) => {
|
|
4872
4872
|
stream.once("error", reject);
|
|
4873
4873
|
stream.on("data", (entry) => entries.push(entry));
|
|
4874
|
-
stream.once("end", () =>
|
|
4874
|
+
stream.once("end", () => resolve(entries));
|
|
4875
4875
|
});
|
|
4876
4876
|
}
|
|
4877
4877
|
};
|
|
@@ -5540,127 +5540,10 @@ var import_node_fs3 = require("fs");
|
|
|
5540
5540
|
var import_node_process4 = __toESM(require("process"), 1);
|
|
5541
5541
|
var import_unplugin = require("unplugin");
|
|
5542
5542
|
|
|
5543
|
-
// src/core/generate.ts
|
|
5544
|
-
var import_node_path = __toESM(require("path"), 1);
|
|
5545
|
-
var import_node_fs = require("fs");
|
|
5546
|
-
var import_node_process = __toESM(require("process"), 1);
|
|
5547
|
-
var import_fast_glob = __toESM(require_out4(), 1);
|
|
5548
|
-
var import_recast = __toESM(require("recast"), 1);
|
|
5549
|
-
function mergeObjects(prodObj, devObj) {
|
|
5550
|
-
const prodProps = new Map(prodObj.properties.map((p) => [p.key.name || p.key.value, p]));
|
|
5551
|
-
for (const prop of devObj.properties) {
|
|
5552
|
-
const key = prop.key.name || prop.key.value;
|
|
5553
|
-
if (prodProps.has(key)) {
|
|
5554
|
-
const index = prodObj.properties.indexOf(prodProps.get(key));
|
|
5555
|
-
if (index >= 0)
|
|
5556
|
-
prodObj.properties[index] = prop;
|
|
5557
|
-
} else {
|
|
5558
|
-
prodObj.properties.push(prop);
|
|
5559
|
-
}
|
|
5560
|
-
}
|
|
5561
|
-
}
|
|
5562
|
-
async function generateScript(options, mode, base2) {
|
|
5563
|
-
const { dir, fileName, globalName, serve, build } = options.env;
|
|
5564
|
-
const folder = await findFolder(import_node_process.default.cwd(), dir);
|
|
5565
|
-
const files = await (0, import_fast_glob.default)("*.+(js|ts)", {
|
|
5566
|
-
absolute: true,
|
|
5567
|
-
cwd: folder
|
|
5568
|
-
});
|
|
5569
|
-
const testReg = mode === "serve" ? serve : build;
|
|
5570
|
-
let target = "";
|
|
5571
|
-
let source = "";
|
|
5572
|
-
let code = "";
|
|
5573
|
-
const name = fileName;
|
|
5574
|
-
for (const file of files) {
|
|
5575
|
-
try {
|
|
5576
|
-
const mod = await import_node_fs.promises.readFile(file, "utf-8");
|
|
5577
|
-
if (testReg == null ? void 0 : testReg.test(file))
|
|
5578
|
-
target = mod;
|
|
5579
|
-
else
|
|
5580
|
-
source = mod;
|
|
5581
|
-
} catch (error) {
|
|
5582
|
-
console.error(`Error loading file ${file}:`, error);
|
|
5583
|
-
}
|
|
5584
|
-
}
|
|
5585
|
-
const targetAst = import_recast.default.parse(target);
|
|
5586
|
-
const sourceAst = import_recast.default.parse(source);
|
|
5587
|
-
const targetExport = targetAst.program.body.find((n) => n.type === "ExportDefaultDeclaration").declaration;
|
|
5588
|
-
const sourceExport = sourceAst.program.body.find((n) => n.type === "ExportDefaultDeclaration").declaration;
|
|
5589
|
-
mergeObjects(sourceExport, targetExport);
|
|
5590
|
-
const mergedCode = import_recast.default.print(sourceExport).code;
|
|
5591
|
-
const returnedTarget = mergedCode;
|
|
5592
|
-
const versionInfo = await generateVersion(options, mode);
|
|
5593
|
-
code = `window.${globalName}=${returnedTarget};${versionInfo}`;
|
|
5594
|
-
const formatCode = code;
|
|
5595
|
-
return {
|
|
5596
|
-
code,
|
|
5597
|
-
script: ` <script type="text/javascript" src="${base2}${fileName}"></script>
|
|
5598
|
-
</head>`,
|
|
5599
|
-
emit: {
|
|
5600
|
-
type: "asset",
|
|
5601
|
-
fileName: name,
|
|
5602
|
-
source: formatCode
|
|
5603
|
-
},
|
|
5604
|
-
watchFiles: files
|
|
5605
|
-
};
|
|
5606
|
-
}
|
|
5607
|
-
async function generateVersion(options, mode) {
|
|
5608
|
-
const packageFile = await (0, import_fast_glob.default)("package.json", {
|
|
5609
|
-
absolute: true,
|
|
5610
|
-
cwd: (0, import_node_path.resolve)(import_node_process.default.cwd())
|
|
5611
|
-
});
|
|
5612
|
-
const packageString = await import_node_fs.promises.readFile(packageFile[0], "utf8");
|
|
5613
|
-
const packageJson = JSON.parse(packageString);
|
|
5614
|
-
return `console.info("Version: ${packageJson.version} - ${mode === "serve" ? "runtime" : "built"} on ${options.date}")`;
|
|
5615
|
-
}
|
|
5616
|
-
async function findFolder(directoryPath, dir) {
|
|
5617
|
-
const ignore = /* @__PURE__ */ new Set(["dist", "node_modules", "playground", "example", "test", "jest", "tests", "locales", "public", ".git", ".github", ".vscode"]);
|
|
5618
|
-
const files = await import_node_fs.promises.readdir(directoryPath);
|
|
5619
|
-
const filePaths = files.filter((item) => !ignore.has(item));
|
|
5620
|
-
let nestedFolder = "";
|
|
5621
|
-
for (const file of filePaths) {
|
|
5622
|
-
const fullFilePath = import_node_path.default.join(directoryPath, file);
|
|
5623
|
-
const stat = await import_node_fs.promises.stat(fullFilePath);
|
|
5624
|
-
if (stat.isDirectory()) {
|
|
5625
|
-
if (file.toLowerCase() === dir) {
|
|
5626
|
-
return fullFilePath;
|
|
5627
|
-
} else {
|
|
5628
|
-
nestedFolder = await findFolder(fullFilePath, dir);
|
|
5629
|
-
if (nestedFolder)
|
|
5630
|
-
return nestedFolder;
|
|
5631
|
-
}
|
|
5632
|
-
}
|
|
5633
|
-
}
|
|
5634
|
-
return "";
|
|
5635
|
-
}
|
|
5636
|
-
|
|
5637
|
-
// src/core/options.ts
|
|
5638
|
-
var import_utils = require("@antfu/utils");
|
|
5639
|
-
function resolveOptions(options) {
|
|
5640
|
-
const defaults = {
|
|
5641
|
-
env: {
|
|
5642
|
-
dir: "config",
|
|
5643
|
-
fileName: "manifest.js",
|
|
5644
|
-
globalName: "manifest",
|
|
5645
|
-
serve: /dev|development/i,
|
|
5646
|
-
build: /prod|production/i
|
|
5647
|
-
},
|
|
5648
|
-
compress: {
|
|
5649
|
-
outDir: "dist",
|
|
5650
|
-
ignoreBase: true
|
|
5651
|
-
}
|
|
5652
|
-
};
|
|
5653
|
-
const mergeOptions = (0, import_utils.deepMerge)(defaults, options);
|
|
5654
|
-
return {
|
|
5655
|
-
...mergeOptions,
|
|
5656
|
-
date: (/* @__PURE__ */ new Date()).toLocaleString()
|
|
5657
|
-
};
|
|
5658
|
-
}
|
|
5659
|
-
|
|
5660
5543
|
// src/core/compress.ts
|
|
5661
|
-
var
|
|
5662
|
-
var
|
|
5663
|
-
var
|
|
5544
|
+
var import_node_fs = __toESM(require("fs"), 1);
|
|
5545
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
5546
|
+
var import_node_process2 = __toESM(require("process"), 1);
|
|
5664
5547
|
var import_archiver = __toESM(require("archiver"), 1);
|
|
5665
5548
|
|
|
5666
5549
|
// node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
@@ -5850,16 +5733,16 @@ var ansiStyles = assembleStyles();
|
|
|
5850
5733
|
var ansi_styles_default = ansiStyles;
|
|
5851
5734
|
|
|
5852
5735
|
// node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/supports-color/index.js
|
|
5853
|
-
var
|
|
5736
|
+
var import_node_process = __toESM(require("process"), 1);
|
|
5854
5737
|
var import_node_os = __toESM(require("os"), 1);
|
|
5855
5738
|
var import_node_tty = __toESM(require("tty"), 1);
|
|
5856
|
-
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args :
|
|
5739
|
+
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
|
|
5857
5740
|
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
5858
5741
|
const position = argv.indexOf(prefix + flag);
|
|
5859
5742
|
const terminatorPosition = argv.indexOf("--");
|
|
5860
5743
|
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
5861
5744
|
}
|
|
5862
|
-
var { env } =
|
|
5745
|
+
var { env } = import_node_process.default;
|
|
5863
5746
|
var flagForceColor;
|
|
5864
5747
|
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
5865
5748
|
flagForceColor = 0;
|
|
@@ -5915,7 +5798,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
|
5915
5798
|
if (env.TERM === "dumb") {
|
|
5916
5799
|
return min;
|
|
5917
5800
|
}
|
|
5918
|
-
if (
|
|
5801
|
+
if (import_node_process.default.platform === "win32") {
|
|
5919
5802
|
const osRelease = import_node_os.default.release().split(".");
|
|
5920
5803
|
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
5921
5804
|
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
@@ -6173,17 +6056,19 @@ var Log = class {
|
|
|
6173
6056
|
};
|
|
6174
6057
|
|
|
6175
6058
|
// src/core/compress.ts
|
|
6176
|
-
async function createCompress(options) {
|
|
6177
|
-
const {
|
|
6178
|
-
const zipFilePath =
|
|
6179
|
-
Log.log("Compressing the directory",
|
|
6180
|
-
return new Promise((
|
|
6059
|
+
async function createCompress(options, outDir2) {
|
|
6060
|
+
const { ignoreBase } = options;
|
|
6061
|
+
const zipFilePath = import_node_path.default.resolve(import_node_process2.default.cwd(), `${import_node_path.default.basename(outDir2)}.zip`);
|
|
6062
|
+
Log.log("Compressing the directory", outDir2);
|
|
6063
|
+
return new Promise((resolve, reject) => {
|
|
6181
6064
|
try {
|
|
6182
|
-
const output =
|
|
6065
|
+
const output = import_node_fs.default.createWriteStream(zipFilePath);
|
|
6183
6066
|
const archive = (0, import_archiver.default)("zip");
|
|
6184
6067
|
output.on("close", () => {
|
|
6185
|
-
|
|
6186
|
-
|
|
6068
|
+
const size = archive.pointer();
|
|
6069
|
+
const sizeInMB = size > 1024 * 1024 ? `${(size / 1024 / 1024).toFixed(1)} MB` : `${(size / 1024).toFixed(1)} KB`;
|
|
6070
|
+
Log.success("Successfully compressed to", `${zipFilePath} (${sizeInMB})`);
|
|
6071
|
+
resolve(null);
|
|
6187
6072
|
});
|
|
6188
6073
|
archive.on("warning", (err) => {
|
|
6189
6074
|
if (err.code === "ENOENT")
|
|
@@ -6196,8 +6081,8 @@ async function createCompress(options) {
|
|
|
6196
6081
|
reject(err);
|
|
6197
6082
|
});
|
|
6198
6083
|
archive.pipe(output);
|
|
6199
|
-
const absoluteOutDir =
|
|
6200
|
-
archive.directory(absoluteOutDir, ignoreBase ? false :
|
|
6084
|
+
const absoluteOutDir = import_node_path.default.resolve(outDir2);
|
|
6085
|
+
archive.directory(absoluteOutDir, ignoreBase ? false : import_node_path.default.basename(outDir2));
|
|
6201
6086
|
archive.finalize();
|
|
6202
6087
|
} catch (error) {
|
|
6203
6088
|
Log.error("Error compressing the directory", error);
|
|
@@ -6206,10 +6091,128 @@ async function createCompress(options) {
|
|
|
6206
6091
|
});
|
|
6207
6092
|
}
|
|
6208
6093
|
|
|
6094
|
+
// src/core/generate.ts
|
|
6095
|
+
var import_node_fs2 = require("fs");
|
|
6096
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
6097
|
+
var import_node_process3 = __toESM(require("process"), 1);
|
|
6098
|
+
var import_fast_glob = __toESM(require_out4(), 1);
|
|
6099
|
+
var import_local_pkg = require("local-pkg");
|
|
6100
|
+
var import_recast = __toESM(require("recast"), 1);
|
|
6101
|
+
function mergeObjects(prodObj, devObj) {
|
|
6102
|
+
const prodProps = new Map(prodObj.properties.map((p) => [p.key.name || p.key.value, p]));
|
|
6103
|
+
for (const prop of devObj.properties) {
|
|
6104
|
+
const key = prop.key.name || prop.key.value;
|
|
6105
|
+
if (prodProps.has(key)) {
|
|
6106
|
+
const index = prodObj.properties.indexOf(prodProps.get(key));
|
|
6107
|
+
if (index >= 0)
|
|
6108
|
+
prodObj.properties[index] = prop;
|
|
6109
|
+
} else {
|
|
6110
|
+
prodObj.properties.push(prop);
|
|
6111
|
+
}
|
|
6112
|
+
}
|
|
6113
|
+
}
|
|
6114
|
+
async function generateScript(options, mode, base2) {
|
|
6115
|
+
const { dir, fileName, globalName, serve, build } = options.env;
|
|
6116
|
+
const folder = await findFolder(import_node_process3.default.cwd(), dir);
|
|
6117
|
+
const files = await (0, import_fast_glob.default)("*.+(js|ts)", {
|
|
6118
|
+
absolute: true,
|
|
6119
|
+
cwd: folder
|
|
6120
|
+
});
|
|
6121
|
+
const testReg = mode === "serve" ? serve : build;
|
|
6122
|
+
let target = "";
|
|
6123
|
+
let source = "";
|
|
6124
|
+
let code = "";
|
|
6125
|
+
const name = fileName;
|
|
6126
|
+
for (const file of files) {
|
|
6127
|
+
try {
|
|
6128
|
+
const mod = await import_node_fs2.promises.readFile(file, "utf-8");
|
|
6129
|
+
if (testReg?.test(file))
|
|
6130
|
+
target = mod;
|
|
6131
|
+
else
|
|
6132
|
+
source = mod;
|
|
6133
|
+
} catch (error) {
|
|
6134
|
+
console.error(`Error loading file ${file}:`, error);
|
|
6135
|
+
}
|
|
6136
|
+
}
|
|
6137
|
+
const targetAst = import_recast.default.parse(target);
|
|
6138
|
+
const sourceAst = import_recast.default.parse(source);
|
|
6139
|
+
const targetExport = targetAst.program.body.find((n) => n.type === "ExportDefaultDeclaration").declaration;
|
|
6140
|
+
const sourceExport = sourceAst.program.body.find((n) => n.type === "ExportDefaultDeclaration").declaration;
|
|
6141
|
+
mergeObjects(sourceExport, targetExport);
|
|
6142
|
+
const mergedCode = import_recast.default.print(sourceExport).code;
|
|
6143
|
+
const returnedTarget = mergedCode;
|
|
6144
|
+
const versionInfo = await generateVersion(options, mode);
|
|
6145
|
+
code = `window.${globalName}=${returnedTarget};
|
|
6146
|
+
${versionInfo}`;
|
|
6147
|
+
const formatCode = code;
|
|
6148
|
+
return {
|
|
6149
|
+
code,
|
|
6150
|
+
script: ` <script type="text/javascript" src="${base2}${fileName}"></script>
|
|
6151
|
+
</head>`,
|
|
6152
|
+
emit: {
|
|
6153
|
+
type: "asset",
|
|
6154
|
+
fileName: name,
|
|
6155
|
+
source: formatCode
|
|
6156
|
+
},
|
|
6157
|
+
watchFiles: files
|
|
6158
|
+
};
|
|
6159
|
+
}
|
|
6160
|
+
async function generateVersion(options, mode) {
|
|
6161
|
+
const pkg = await (0, import_local_pkg.getPackageInfo)(import_node_process3.default.cwd());
|
|
6162
|
+
return `console.info("Version: %c${pkg?.version}%c - ${mode === "serve" ? "runtime" : "built"} on %c${options.datetime}%c", "color: green;", '', "color: blue;", '')`;
|
|
6163
|
+
}
|
|
6164
|
+
async function findFolder(directoryPath, dir) {
|
|
6165
|
+
const ignore = /* @__PURE__ */ new Set(["dist", "node_modules", "playground", "example", "test", "jest", "tests", "locales", "public", ".git", ".github", ".vscode"]);
|
|
6166
|
+
const files = await import_node_fs2.promises.readdir(directoryPath);
|
|
6167
|
+
const filePaths = files.filter((item) => !ignore.has(item));
|
|
6168
|
+
let nestedFolder = "";
|
|
6169
|
+
for (const file of filePaths) {
|
|
6170
|
+
const fullFilePath = import_node_path2.default.join(directoryPath, file);
|
|
6171
|
+
const stat = await import_node_fs2.promises.stat(fullFilePath);
|
|
6172
|
+
if (stat.isDirectory()) {
|
|
6173
|
+
if (file.toLowerCase() === dir) {
|
|
6174
|
+
return fullFilePath;
|
|
6175
|
+
} else {
|
|
6176
|
+
nestedFolder = await findFolder(fullFilePath, dir);
|
|
6177
|
+
if (nestedFolder)
|
|
6178
|
+
return nestedFolder;
|
|
6179
|
+
}
|
|
6180
|
+
}
|
|
6181
|
+
}
|
|
6182
|
+
return "";
|
|
6183
|
+
}
|
|
6184
|
+
|
|
6185
|
+
// src/core/options.ts
|
|
6186
|
+
var import_utils = require("@antfu/utils");
|
|
6187
|
+
function resolveOptions(options) {
|
|
6188
|
+
const defaults = {
|
|
6189
|
+
env: {
|
|
6190
|
+
dir: "config",
|
|
6191
|
+
fileName: "manifest.js",
|
|
6192
|
+
globalName: "manifest",
|
|
6193
|
+
serve: /dev/i,
|
|
6194
|
+
build: /prod/i
|
|
6195
|
+
},
|
|
6196
|
+
compress: {
|
|
6197
|
+
ignoreBase: false
|
|
6198
|
+
}
|
|
6199
|
+
};
|
|
6200
|
+
const mergeOptions = (0, import_utils.deepMerge)(defaults, options);
|
|
6201
|
+
const formatter = new Intl.DateTimeFormat("zh-CN", {
|
|
6202
|
+
dateStyle: "full",
|
|
6203
|
+
timeStyle: "medium"
|
|
6204
|
+
});
|
|
6205
|
+
return {
|
|
6206
|
+
...mergeOptions,
|
|
6207
|
+
datetime: formatter.format(/* @__PURE__ */ new Date())
|
|
6208
|
+
};
|
|
6209
|
+
}
|
|
6210
|
+
|
|
6209
6211
|
// src/index.ts
|
|
6210
6212
|
var virtualEnvId = "virtual:env";
|
|
6211
6213
|
var resolvedVirtualEnvId = `\0${virtualEnvId}`;
|
|
6212
6214
|
var base = "";
|
|
6215
|
+
var outDir = "";
|
|
6213
6216
|
var unpluginFactory = (options = {}) => {
|
|
6214
6217
|
const resolved = resolveOptions(options);
|
|
6215
6218
|
return [{
|
|
@@ -6217,6 +6220,7 @@ var unpluginFactory = (options = {}) => {
|
|
|
6217
6220
|
apply: "serve",
|
|
6218
6221
|
enforce: "post",
|
|
6219
6222
|
configResolved(config) {
|
|
6223
|
+
outDir = config.build.outDir;
|
|
6220
6224
|
base = config.base;
|
|
6221
6225
|
},
|
|
6222
6226
|
async resolveId(id) {
|
|
@@ -6238,6 +6242,7 @@ var unpluginFactory = (options = {}) => {
|
|
|
6238
6242
|
enforce: "post",
|
|
6239
6243
|
configResolved(config) {
|
|
6240
6244
|
base = config.base;
|
|
6245
|
+
outDir = config.build.outDir;
|
|
6241
6246
|
},
|
|
6242
6247
|
resolveId(id) {
|
|
6243
6248
|
if (id.startsWith(virtualEnvId))
|
|
@@ -6261,7 +6266,7 @@ var unpluginFactory = (options = {}) => {
|
|
|
6261
6266
|
buildEnd: () => {
|
|
6262
6267
|
import_node_process4.default.on("beforeExit", async () => {
|
|
6263
6268
|
const { compress } = resolved;
|
|
6264
|
-
await createCompress(compress);
|
|
6269
|
+
await createCompress(compress, outDir);
|
|
6265
6270
|
import_node_process4.default.exit(0);
|
|
6266
6271
|
});
|
|
6267
6272
|
}
|