unplugin-env 1.0.1 → 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.
@@ -5,7 +5,7 @@
5
5
 
6
6
  import {
7
7
  unpluginFactory
8
- } from "./chunk-QWCQIGEO.js";
8
+ } from "./chunk-V2T5VQQ7.js";
9
9
 
10
10
  // src/webpack.ts
11
11
  import { createWebpackPlugin } from "unplugin";
@@ -5,7 +5,7 @@
5
5
 
6
6
  import {
7
7
  unpluginFactory
8
- } from "./chunk-QWCQIGEO.js";
8
+ } from "./chunk-V2T5VQQ7.js";
9
9
 
10
10
  // src/vite.ts
11
11
  import { createVitePlugin } from "unplugin";
@@ -6049,16 +6049,18 @@ var Log = class {
6049
6049
  };
6050
6050
 
6051
6051
  // src/core/compress.ts
6052
- async function createCompress(options) {
6053
- const { outDir, ignoreBase } = options;
6054
- const zipFilePath = path.resolve(process3.cwd(), `${path.basename(outDir)}.zip`);
6055
- Log.log("Compressing the directory", outDir);
6052
+ async function createCompress(options, outDir2) {
6053
+ const { ignoreBase } = options;
6054
+ const zipFilePath = path.resolve(process3.cwd(), `${path.basename(outDir2)}.zip`);
6055
+ Log.log("Compressing the directory", outDir2);
6056
6056
  return new Promise((resolve, reject) => {
6057
6057
  try {
6058
6058
  const output = fs.createWriteStream(zipFilePath);
6059
6059
  const archive = archiver("zip");
6060
6060
  output.on("close", () => {
6061
- Log.success("Successfully compressed to", `${zipFilePath} (${(archive.pointer() / 1024 / 1024).toFixed(1)} MB)`);
6061
+ const size = archive.pointer();
6062
+ const sizeInMB = size > 1024 * 1024 ? `${(size / 1024 / 1024).toFixed(1)} MB` : `${(size / 1024).toFixed(1)} KB`;
6063
+ Log.success("Successfully compressed to", `${zipFilePath} (${sizeInMB})`);
6062
6064
  resolve(null);
6063
6065
  });
6064
6066
  archive.on("warning", (err) => {
@@ -6072,8 +6074,8 @@ async function createCompress(options) {
6072
6074
  reject(err);
6073
6075
  });
6074
6076
  archive.pipe(output);
6075
- const absoluteOutDir = path.resolve(outDir);
6076
- archive.directory(absoluteOutDir, ignoreBase ? false : path.basename(outDir));
6077
+ const absoluteOutDir = path.resolve(outDir2);
6078
+ archive.directory(absoluteOutDir, ignoreBase ? false : path.basename(outDir2));
6077
6079
  archive.finalize();
6078
6080
  } catch (error) {
6079
6081
  Log.error("Error compressing the directory", error);
@@ -6150,7 +6152,7 @@ ${versionInfo}`;
6150
6152
  }
6151
6153
  async function generateVersion(options, mode) {
6152
6154
  const pkg = await getPackageInfo(process4.cwd());
6153
- return `console.info("Version: %c${pkg?.version}%c - ${mode === "serve" ? "runtime" : "built"} on %c${options.date}%c", "color: green;", '', "color: blue;", '')`;
6155
+ return `console.info("Version: %c${pkg?.version}%c - ${mode === "serve" ? "runtime" : "built"} on %c${options.datetime}%c", "color: green;", '', "color: blue;", '')`;
6154
6156
  }
6155
6157
  async function findFolder(directoryPath, dir) {
6156
6158
  const ignore = /* @__PURE__ */ new Set(["dist", "node_modules", "playground", "example", "test", "jest", "tests", "locales", "public", ".git", ".github", ".vscode"]);
@@ -6185,8 +6187,7 @@ function resolveOptions(options) {
6185
6187
  build: /prod/i
6186
6188
  },
6187
6189
  compress: {
6188
- outDir: "dist",
6189
- ignoreBase: true
6190
+ ignoreBase: false
6190
6191
  }
6191
6192
  };
6192
6193
  const mergeOptions = deepMerge(defaults, options);
@@ -6196,7 +6197,7 @@ function resolveOptions(options) {
6196
6197
  });
6197
6198
  return {
6198
6199
  ...mergeOptions,
6199
- date: formatter.format(/* @__PURE__ */ new Date())
6200
+ datetime: formatter.format(/* @__PURE__ */ new Date())
6200
6201
  };
6201
6202
  }
6202
6203
 
@@ -6204,6 +6205,7 @@ function resolveOptions(options) {
6204
6205
  var virtualEnvId = "virtual:env";
6205
6206
  var resolvedVirtualEnvId = `\0${virtualEnvId}`;
6206
6207
  var base = "";
6208
+ var outDir = "";
6207
6209
  var unpluginFactory = (options = {}) => {
6208
6210
  const resolved = resolveOptions(options);
6209
6211
  return [{
@@ -6211,6 +6213,7 @@ var unpluginFactory = (options = {}) => {
6211
6213
  apply: "serve",
6212
6214
  enforce: "post",
6213
6215
  configResolved(config) {
6216
+ outDir = config.build.outDir;
6214
6217
  base = config.base;
6215
6218
  },
6216
6219
  async resolveId(id) {
@@ -6232,6 +6235,7 @@ var unpluginFactory = (options = {}) => {
6232
6235
  enforce: "post",
6233
6236
  configResolved(config) {
6234
6237
  base = config.base;
6238
+ outDir = config.build.outDir;
6235
6239
  },
6236
6240
  resolveId(id) {
6237
6241
  if (id.startsWith(virtualEnvId))
@@ -6255,7 +6259,7 @@ var unpluginFactory = (options = {}) => {
6255
6259
  buildEnd: () => {
6256
6260
  process5.on("beforeExit", async () => {
6257
6261
  const { compress } = resolved;
6258
- await createCompress(compress);
6262
+ await createCompress(compress, outDir);
6259
6263
  process5.exit(0);
6260
6264
  });
6261
6265
  }
package/dist/esbuild.cjs CHANGED
@@ -6057,16 +6057,18 @@ var Log = class {
6057
6057
  };
6058
6058
 
6059
6059
  // src/core/compress.ts
6060
- async function createCompress(options) {
6061
- const { outDir, ignoreBase } = options;
6062
- const zipFilePath = import_node_path.default.resolve(import_node_process2.default.cwd(), `${import_node_path.default.basename(outDir)}.zip`);
6063
- Log.log("Compressing the directory", outDir);
6060
+ async function createCompress(options, outDir2) {
6061
+ const { ignoreBase } = options;
6062
+ const zipFilePath = import_node_path.default.resolve(import_node_process2.default.cwd(), `${import_node_path.default.basename(outDir2)}.zip`);
6063
+ Log.log("Compressing the directory", outDir2);
6064
6064
  return new Promise((resolve, reject) => {
6065
6065
  try {
6066
6066
  const output = import_node_fs.default.createWriteStream(zipFilePath);
6067
6067
  const archive = (0, import_archiver.default)("zip");
6068
6068
  output.on("close", () => {
6069
- Log.success("Successfully compressed to", `${zipFilePath} (${(archive.pointer() / 1024 / 1024).toFixed(1)} MB)`);
6069
+ const size = archive.pointer();
6070
+ const sizeInMB = size > 1024 * 1024 ? `${(size / 1024 / 1024).toFixed(1)} MB` : `${(size / 1024).toFixed(1)} KB`;
6071
+ Log.success("Successfully compressed to", `${zipFilePath} (${sizeInMB})`);
6070
6072
  resolve(null);
6071
6073
  });
6072
6074
  archive.on("warning", (err) => {
@@ -6080,8 +6082,8 @@ async function createCompress(options) {
6080
6082
  reject(err);
6081
6083
  });
6082
6084
  archive.pipe(output);
6083
- const absoluteOutDir = import_node_path.default.resolve(outDir);
6084
- archive.directory(absoluteOutDir, ignoreBase ? false : import_node_path.default.basename(outDir));
6085
+ const absoluteOutDir = import_node_path.default.resolve(outDir2);
6086
+ archive.directory(absoluteOutDir, ignoreBase ? false : import_node_path.default.basename(outDir2));
6085
6087
  archive.finalize();
6086
6088
  } catch (error) {
6087
6089
  Log.error("Error compressing the directory", error);
@@ -6158,7 +6160,7 @@ ${versionInfo}`;
6158
6160
  }
6159
6161
  async function generateVersion(options, mode) {
6160
6162
  const pkg = await (0, import_local_pkg.getPackageInfo)(import_node_process3.default.cwd());
6161
- return `console.info("Version: %c${pkg?.version}%c - ${mode === "serve" ? "runtime" : "built"} on %c${options.date}%c", "color: green;", '', "color: blue;", '')`;
6163
+ return `console.info("Version: %c${pkg?.version}%c - ${mode === "serve" ? "runtime" : "built"} on %c${options.datetime}%c", "color: green;", '', "color: blue;", '')`;
6162
6164
  }
6163
6165
  async function findFolder(directoryPath, dir) {
6164
6166
  const ignore = /* @__PURE__ */ new Set(["dist", "node_modules", "playground", "example", "test", "jest", "tests", "locales", "public", ".git", ".github", ".vscode"]);
@@ -6193,8 +6195,7 @@ function resolveOptions(options) {
6193
6195
  build: /prod/i
6194
6196
  },
6195
6197
  compress: {
6196
- outDir: "dist",
6197
- ignoreBase: true
6198
+ ignoreBase: false
6198
6199
  }
6199
6200
  };
6200
6201
  const mergeOptions = (0, import_utils.deepMerge)(defaults, options);
@@ -6204,7 +6205,7 @@ function resolveOptions(options) {
6204
6205
  });
6205
6206
  return {
6206
6207
  ...mergeOptions,
6207
- date: formatter.format(/* @__PURE__ */ new Date())
6208
+ datetime: formatter.format(/* @__PURE__ */ new Date())
6208
6209
  };
6209
6210
  }
6210
6211
 
@@ -6212,6 +6213,7 @@ function resolveOptions(options) {
6212
6213
  var virtualEnvId = "virtual:env";
6213
6214
  var resolvedVirtualEnvId = `\0${virtualEnvId}`;
6214
6215
  var base = "";
6216
+ var outDir = "";
6215
6217
  var unpluginFactory = (options = {}) => {
6216
6218
  const resolved = resolveOptions(options);
6217
6219
  return [{
@@ -6219,6 +6221,7 @@ var unpluginFactory = (options = {}) => {
6219
6221
  apply: "serve",
6220
6222
  enforce: "post",
6221
6223
  configResolved(config) {
6224
+ outDir = config.build.outDir;
6222
6225
  base = config.base;
6223
6226
  },
6224
6227
  async resolveId(id) {
@@ -6240,6 +6243,7 @@ var unpluginFactory = (options = {}) => {
6240
6243
  enforce: "post",
6241
6244
  configResolved(config) {
6242
6245
  base = config.base;
6246
+ outDir = config.build.outDir;
6243
6247
  },
6244
6248
  resolveId(id) {
6245
6249
  if (id.startsWith(virtualEnvId))
@@ -6263,7 +6267,7 @@ var unpluginFactory = (options = {}) => {
6263
6267
  buildEnd: () => {
6264
6268
  import_node_process4.default.on("beforeExit", async () => {
6265
6269
  const { compress } = resolved;
6266
- await createCompress(compress);
6270
+ await createCompress(compress, outDir);
6267
6271
  import_node_process4.default.exit(0);
6268
6272
  });
6269
6273
  }
package/dist/esbuild.js CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  import {
7
7
  unpluginFactory
8
- } from "./chunk-QWCQIGEO.js";
8
+ } from "./chunk-V2T5VQQ7.js";
9
9
 
10
10
  // src/esbuild.ts
11
11
  import { createEsbuildPlugin } from "unplugin";
package/dist/index.cjs CHANGED
@@ -6056,16 +6056,18 @@ var Log = class {
6056
6056
  };
6057
6057
 
6058
6058
  // src/core/compress.ts
6059
- async function createCompress(options) {
6060
- const { outDir, ignoreBase } = options;
6061
- const zipFilePath = import_node_path.default.resolve(import_node_process2.default.cwd(), `${import_node_path.default.basename(outDir)}.zip`);
6062
- Log.log("Compressing the directory", outDir);
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
6063
  return new Promise((resolve, reject) => {
6064
6064
  try {
6065
6065
  const output = import_node_fs.default.createWriteStream(zipFilePath);
6066
6066
  const archive = (0, import_archiver.default)("zip");
6067
6067
  output.on("close", () => {
6068
- Log.success("Successfully compressed to", `${zipFilePath} (${(archive.pointer() / 1024 / 1024).toFixed(1)} MB)`);
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})`);
6069
6071
  resolve(null);
6070
6072
  });
6071
6073
  archive.on("warning", (err) => {
@@ -6079,8 +6081,8 @@ async function createCompress(options) {
6079
6081
  reject(err);
6080
6082
  });
6081
6083
  archive.pipe(output);
6082
- const absoluteOutDir = import_node_path.default.resolve(outDir);
6083
- archive.directory(absoluteOutDir, ignoreBase ? false : import_node_path.default.basename(outDir));
6084
+ const absoluteOutDir = import_node_path.default.resolve(outDir2);
6085
+ archive.directory(absoluteOutDir, ignoreBase ? false : import_node_path.default.basename(outDir2));
6084
6086
  archive.finalize();
6085
6087
  } catch (error) {
6086
6088
  Log.error("Error compressing the directory", error);
@@ -6157,7 +6159,7 @@ ${versionInfo}`;
6157
6159
  }
6158
6160
  async function generateVersion(options, mode) {
6159
6161
  const pkg = await (0, import_local_pkg.getPackageInfo)(import_node_process3.default.cwd());
6160
- return `console.info("Version: %c${pkg?.version}%c - ${mode === "serve" ? "runtime" : "built"} on %c${options.date}%c", "color: green;", '', "color: blue;", '')`;
6162
+ return `console.info("Version: %c${pkg?.version}%c - ${mode === "serve" ? "runtime" : "built"} on %c${options.datetime}%c", "color: green;", '', "color: blue;", '')`;
6161
6163
  }
6162
6164
  async function findFolder(directoryPath, dir) {
6163
6165
  const ignore = /* @__PURE__ */ new Set(["dist", "node_modules", "playground", "example", "test", "jest", "tests", "locales", "public", ".git", ".github", ".vscode"]);
@@ -6192,8 +6194,7 @@ function resolveOptions(options) {
6192
6194
  build: /prod/i
6193
6195
  },
6194
6196
  compress: {
6195
- outDir: "dist",
6196
- ignoreBase: true
6197
+ ignoreBase: false
6197
6198
  }
6198
6199
  };
6199
6200
  const mergeOptions = (0, import_utils.deepMerge)(defaults, options);
@@ -6203,7 +6204,7 @@ function resolveOptions(options) {
6203
6204
  });
6204
6205
  return {
6205
6206
  ...mergeOptions,
6206
- date: formatter.format(/* @__PURE__ */ new Date())
6207
+ datetime: formatter.format(/* @__PURE__ */ new Date())
6207
6208
  };
6208
6209
  }
6209
6210
 
@@ -6211,6 +6212,7 @@ function resolveOptions(options) {
6211
6212
  var virtualEnvId = "virtual:env";
6212
6213
  var resolvedVirtualEnvId = `\0${virtualEnvId}`;
6213
6214
  var base = "";
6215
+ var outDir = "";
6214
6216
  var unpluginFactory = (options = {}) => {
6215
6217
  const resolved = resolveOptions(options);
6216
6218
  return [{
@@ -6218,6 +6220,7 @@ var unpluginFactory = (options = {}) => {
6218
6220
  apply: "serve",
6219
6221
  enforce: "post",
6220
6222
  configResolved(config) {
6223
+ outDir = config.build.outDir;
6221
6224
  base = config.base;
6222
6225
  },
6223
6226
  async resolveId(id) {
@@ -6239,6 +6242,7 @@ var unpluginFactory = (options = {}) => {
6239
6242
  enforce: "post",
6240
6243
  configResolved(config) {
6241
6244
  base = config.base;
6245
+ outDir = config.build.outDir;
6242
6246
  },
6243
6247
  resolveId(id) {
6244
6248
  if (id.startsWith(virtualEnvId))
@@ -6262,7 +6266,7 @@ var unpluginFactory = (options = {}) => {
6262
6266
  buildEnd: () => {
6263
6267
  import_node_process4.default.on("beforeExit", async () => {
6264
6268
  const { compress } = resolved;
6265
- await createCompress(compress);
6269
+ await createCompress(compress, outDir);
6266
6270
  import_node_process4.default.exit(0);
6267
6271
  });
6268
6272
  }
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  index_default,
8
8
  unplugin,
9
9
  unpluginFactory
10
- } from "./chunk-QWCQIGEO.js";
10
+ } from "./chunk-V2T5VQQ7.js";
11
11
  export {
12
12
  index_default as default,
13
13
  unplugin,
package/dist/nuxt.cjs CHANGED
@@ -6060,16 +6060,18 @@ var Log = class {
6060
6060
  };
6061
6061
 
6062
6062
  // src/core/compress.ts
6063
- async function createCompress(options) {
6064
- const { outDir, ignoreBase } = options;
6065
- const zipFilePath = import_node_path.default.resolve(import_node_process2.default.cwd(), `${import_node_path.default.basename(outDir)}.zip`);
6066
- Log.log("Compressing the directory", outDir);
6063
+ async function createCompress(options, outDir2) {
6064
+ const { ignoreBase } = options;
6065
+ const zipFilePath = import_node_path.default.resolve(import_node_process2.default.cwd(), `${import_node_path.default.basename(outDir2)}.zip`);
6066
+ Log.log("Compressing the directory", outDir2);
6067
6067
  return new Promise((resolve, reject) => {
6068
6068
  try {
6069
6069
  const output = import_node_fs.default.createWriteStream(zipFilePath);
6070
6070
  const archive = (0, import_archiver.default)("zip");
6071
6071
  output.on("close", () => {
6072
- Log.success("Successfully compressed to", `${zipFilePath} (${(archive.pointer() / 1024 / 1024).toFixed(1)} MB)`);
6072
+ const size = archive.pointer();
6073
+ const sizeInMB = size > 1024 * 1024 ? `${(size / 1024 / 1024).toFixed(1)} MB` : `${(size / 1024).toFixed(1)} KB`;
6074
+ Log.success("Successfully compressed to", `${zipFilePath} (${sizeInMB})`);
6073
6075
  resolve(null);
6074
6076
  });
6075
6077
  archive.on("warning", (err) => {
@@ -6083,8 +6085,8 @@ async function createCompress(options) {
6083
6085
  reject(err);
6084
6086
  });
6085
6087
  archive.pipe(output);
6086
- const absoluteOutDir = import_node_path.default.resolve(outDir);
6087
- archive.directory(absoluteOutDir, ignoreBase ? false : import_node_path.default.basename(outDir));
6088
+ const absoluteOutDir = import_node_path.default.resolve(outDir2);
6089
+ archive.directory(absoluteOutDir, ignoreBase ? false : import_node_path.default.basename(outDir2));
6088
6090
  archive.finalize();
6089
6091
  } catch (error) {
6090
6092
  Log.error("Error compressing the directory", error);
@@ -6161,7 +6163,7 @@ ${versionInfo}`;
6161
6163
  }
6162
6164
  async function generateVersion(options, mode) {
6163
6165
  const pkg = await (0, import_local_pkg.getPackageInfo)(import_node_process3.default.cwd());
6164
- return `console.info("Version: %c${pkg?.version}%c - ${mode === "serve" ? "runtime" : "built"} on %c${options.date}%c", "color: green;", '', "color: blue;", '')`;
6166
+ return `console.info("Version: %c${pkg?.version}%c - ${mode === "serve" ? "runtime" : "built"} on %c${options.datetime}%c", "color: green;", '', "color: blue;", '')`;
6165
6167
  }
6166
6168
  async function findFolder(directoryPath, dir) {
6167
6169
  const ignore = /* @__PURE__ */ new Set(["dist", "node_modules", "playground", "example", "test", "jest", "tests", "locales", "public", ".git", ".github", ".vscode"]);
@@ -6196,8 +6198,7 @@ function resolveOptions(options) {
6196
6198
  build: /prod/i
6197
6199
  },
6198
6200
  compress: {
6199
- outDir: "dist",
6200
- ignoreBase: true
6201
+ ignoreBase: false
6201
6202
  }
6202
6203
  };
6203
6204
  const mergeOptions = (0, import_utils.deepMerge)(defaults, options);
@@ -6207,7 +6208,7 @@ function resolveOptions(options) {
6207
6208
  });
6208
6209
  return {
6209
6210
  ...mergeOptions,
6210
- date: formatter.format(/* @__PURE__ */ new Date())
6211
+ datetime: formatter.format(/* @__PURE__ */ new Date())
6211
6212
  };
6212
6213
  }
6213
6214
 
@@ -6215,6 +6216,7 @@ function resolveOptions(options) {
6215
6216
  var virtualEnvId = "virtual:env";
6216
6217
  var resolvedVirtualEnvId = `\0${virtualEnvId}`;
6217
6218
  var base = "";
6219
+ var outDir = "";
6218
6220
  var unpluginFactory = (options = {}) => {
6219
6221
  const resolved = resolveOptions(options);
6220
6222
  return [{
@@ -6222,6 +6224,7 @@ var unpluginFactory = (options = {}) => {
6222
6224
  apply: "serve",
6223
6225
  enforce: "post",
6224
6226
  configResolved(config) {
6227
+ outDir = config.build.outDir;
6225
6228
  base = config.base;
6226
6229
  },
6227
6230
  async resolveId(id) {
@@ -6243,6 +6246,7 @@ var unpluginFactory = (options = {}) => {
6243
6246
  enforce: "post",
6244
6247
  configResolved(config) {
6245
6248
  base = config.base;
6249
+ outDir = config.build.outDir;
6246
6250
  },
6247
6251
  resolveId(id) {
6248
6252
  if (id.startsWith(virtualEnvId))
@@ -6266,7 +6270,7 @@ var unpluginFactory = (options = {}) => {
6266
6270
  buildEnd: () => {
6267
6271
  import_node_process4.default.on("beforeExit", async () => {
6268
6272
  const { compress } = resolved;
6269
- await createCompress(compress);
6273
+ await createCompress(compress, outDir);
6270
6274
  import_node_process4.default.exit(0);
6271
6275
  });
6272
6276
  }
package/dist/nuxt.js CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  import {
7
7
  vite_default
8
- } from "./chunk-Y45ERLIW.js";
8
+ } from "./chunk-6I6MSMXF.js";
9
9
  import {
10
10
  webpack_default
11
- } from "./chunk-ELYQVJHH.js";
12
- import "./chunk-QWCQIGEO.js";
11
+ } from "./chunk-664Z6SFJ.js";
12
+ import "./chunk-V2T5VQQ7.js";
13
13
 
14
14
  // src/nuxt.ts
15
15
  import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from "@nuxt/kit";
package/dist/rollup.cjs CHANGED
@@ -6057,16 +6057,18 @@ var Log = class {
6057
6057
  };
6058
6058
 
6059
6059
  // src/core/compress.ts
6060
- async function createCompress(options) {
6061
- const { outDir, ignoreBase } = options;
6062
- const zipFilePath = import_node_path.default.resolve(import_node_process2.default.cwd(), `${import_node_path.default.basename(outDir)}.zip`);
6063
- Log.log("Compressing the directory", outDir);
6060
+ async function createCompress(options, outDir2) {
6061
+ const { ignoreBase } = options;
6062
+ const zipFilePath = import_node_path.default.resolve(import_node_process2.default.cwd(), `${import_node_path.default.basename(outDir2)}.zip`);
6063
+ Log.log("Compressing the directory", outDir2);
6064
6064
  return new Promise((resolve, reject) => {
6065
6065
  try {
6066
6066
  const output = import_node_fs.default.createWriteStream(zipFilePath);
6067
6067
  const archive = (0, import_archiver.default)("zip");
6068
6068
  output.on("close", () => {
6069
- Log.success("Successfully compressed to", `${zipFilePath} (${(archive.pointer() / 1024 / 1024).toFixed(1)} MB)`);
6069
+ const size = archive.pointer();
6070
+ const sizeInMB = size > 1024 * 1024 ? `${(size / 1024 / 1024).toFixed(1)} MB` : `${(size / 1024).toFixed(1)} KB`;
6071
+ Log.success("Successfully compressed to", `${zipFilePath} (${sizeInMB})`);
6070
6072
  resolve(null);
6071
6073
  });
6072
6074
  archive.on("warning", (err) => {
@@ -6080,8 +6082,8 @@ async function createCompress(options) {
6080
6082
  reject(err);
6081
6083
  });
6082
6084
  archive.pipe(output);
6083
- const absoluteOutDir = import_node_path.default.resolve(outDir);
6084
- archive.directory(absoluteOutDir, ignoreBase ? false : import_node_path.default.basename(outDir));
6085
+ const absoluteOutDir = import_node_path.default.resolve(outDir2);
6086
+ archive.directory(absoluteOutDir, ignoreBase ? false : import_node_path.default.basename(outDir2));
6085
6087
  archive.finalize();
6086
6088
  } catch (error) {
6087
6089
  Log.error("Error compressing the directory", error);
@@ -6158,7 +6160,7 @@ ${versionInfo}`;
6158
6160
  }
6159
6161
  async function generateVersion(options, mode) {
6160
6162
  const pkg = await (0, import_local_pkg.getPackageInfo)(import_node_process3.default.cwd());
6161
- return `console.info("Version: %c${pkg?.version}%c - ${mode === "serve" ? "runtime" : "built"} on %c${options.date}%c", "color: green;", '', "color: blue;", '')`;
6163
+ return `console.info("Version: %c${pkg?.version}%c - ${mode === "serve" ? "runtime" : "built"} on %c${options.datetime}%c", "color: green;", '', "color: blue;", '')`;
6162
6164
  }
6163
6165
  async function findFolder(directoryPath, dir) {
6164
6166
  const ignore = /* @__PURE__ */ new Set(["dist", "node_modules", "playground", "example", "test", "jest", "tests", "locales", "public", ".git", ".github", ".vscode"]);
@@ -6193,8 +6195,7 @@ function resolveOptions(options) {
6193
6195
  build: /prod/i
6194
6196
  },
6195
6197
  compress: {
6196
- outDir: "dist",
6197
- ignoreBase: true
6198
+ ignoreBase: false
6198
6199
  }
6199
6200
  };
6200
6201
  const mergeOptions = (0, import_utils.deepMerge)(defaults, options);
@@ -6204,7 +6205,7 @@ function resolveOptions(options) {
6204
6205
  });
6205
6206
  return {
6206
6207
  ...mergeOptions,
6207
- date: formatter.format(/* @__PURE__ */ new Date())
6208
+ datetime: formatter.format(/* @__PURE__ */ new Date())
6208
6209
  };
6209
6210
  }
6210
6211
 
@@ -6212,6 +6213,7 @@ function resolveOptions(options) {
6212
6213
  var virtualEnvId = "virtual:env";
6213
6214
  var resolvedVirtualEnvId = `\0${virtualEnvId}`;
6214
6215
  var base = "";
6216
+ var outDir = "";
6215
6217
  var unpluginFactory = (options = {}) => {
6216
6218
  const resolved = resolveOptions(options);
6217
6219
  return [{
@@ -6219,6 +6221,7 @@ var unpluginFactory = (options = {}) => {
6219
6221
  apply: "serve",
6220
6222
  enforce: "post",
6221
6223
  configResolved(config) {
6224
+ outDir = config.build.outDir;
6222
6225
  base = config.base;
6223
6226
  },
6224
6227
  async resolveId(id) {
@@ -6240,6 +6243,7 @@ var unpluginFactory = (options = {}) => {
6240
6243
  enforce: "post",
6241
6244
  configResolved(config) {
6242
6245
  base = config.base;
6246
+ outDir = config.build.outDir;
6243
6247
  },
6244
6248
  resolveId(id) {
6245
6249
  if (id.startsWith(virtualEnvId))
@@ -6263,7 +6267,7 @@ var unpluginFactory = (options = {}) => {
6263
6267
  buildEnd: () => {
6264
6268
  import_node_process4.default.on("beforeExit", async () => {
6265
6269
  const { compress } = resolved;
6266
- await createCompress(compress);
6270
+ await createCompress(compress, outDir);
6267
6271
  import_node_process4.default.exit(0);
6268
6272
  });
6269
6273
  }
package/dist/rollup.js CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  import {
7
7
  unpluginFactory
8
- } from "./chunk-QWCQIGEO.js";
8
+ } from "./chunk-V2T5VQQ7.js";
9
9
 
10
10
  // src/rollup.ts
11
11
  import { createRollupPlugin } from "unplugin";
package/dist/types.d.cts CHANGED
@@ -27,7 +27,6 @@ interface Options {
27
27
  build?: RegExp;
28
28
  };
29
29
  compress?: {
30
- outDir?: string;
31
30
  ignoreBase?: boolean;
32
31
  };
33
32
  }
@@ -35,7 +34,7 @@ type DeepRequired<T> = {
35
34
  [P in keyof T]-?: T[P] extends object ? DeepRequired<T[P]> : T[P];
36
35
  };
37
36
  type ResolvedOptions = DeepRequired<Options> & {
38
- date: string;
37
+ datetime: string;
39
38
  };
40
39
  interface GenerateScript {
41
40
  code: string;
package/dist/types.d.ts CHANGED
@@ -27,7 +27,6 @@ interface Options {
27
27
  build?: RegExp;
28
28
  };
29
29
  compress?: {
30
- outDir?: string;
31
30
  ignoreBase?: boolean;
32
31
  };
33
32
  }
@@ -35,7 +34,7 @@ type DeepRequired<T> = {
35
34
  [P in keyof T]-?: T[P] extends object ? DeepRequired<T[P]> : T[P];
36
35
  };
37
36
  type ResolvedOptions = DeepRequired<Options> & {
38
- date: string;
37
+ datetime: string;
39
38
  };
40
39
  interface GenerateScript {
41
40
  code: string;
package/dist/vite.cjs CHANGED
@@ -6057,16 +6057,18 @@ var Log = class {
6057
6057
  };
6058
6058
 
6059
6059
  // src/core/compress.ts
6060
- async function createCompress(options) {
6061
- const { outDir, ignoreBase } = options;
6062
- const zipFilePath = import_node_path.default.resolve(import_node_process2.default.cwd(), `${import_node_path.default.basename(outDir)}.zip`);
6063
- Log.log("Compressing the directory", outDir);
6060
+ async function createCompress(options, outDir2) {
6061
+ const { ignoreBase } = options;
6062
+ const zipFilePath = import_node_path.default.resolve(import_node_process2.default.cwd(), `${import_node_path.default.basename(outDir2)}.zip`);
6063
+ Log.log("Compressing the directory", outDir2);
6064
6064
  return new Promise((resolve, reject) => {
6065
6065
  try {
6066
6066
  const output = import_node_fs.default.createWriteStream(zipFilePath);
6067
6067
  const archive = (0, import_archiver.default)("zip");
6068
6068
  output.on("close", () => {
6069
- Log.success("Successfully compressed to", `${zipFilePath} (${(archive.pointer() / 1024 / 1024).toFixed(1)} MB)`);
6069
+ const size = archive.pointer();
6070
+ const sizeInMB = size > 1024 * 1024 ? `${(size / 1024 / 1024).toFixed(1)} MB` : `${(size / 1024).toFixed(1)} KB`;
6071
+ Log.success("Successfully compressed to", `${zipFilePath} (${sizeInMB})`);
6070
6072
  resolve(null);
6071
6073
  });
6072
6074
  archive.on("warning", (err) => {
@@ -6080,8 +6082,8 @@ async function createCompress(options) {
6080
6082
  reject(err);
6081
6083
  });
6082
6084
  archive.pipe(output);
6083
- const absoluteOutDir = import_node_path.default.resolve(outDir);
6084
- archive.directory(absoluteOutDir, ignoreBase ? false : import_node_path.default.basename(outDir));
6085
+ const absoluteOutDir = import_node_path.default.resolve(outDir2);
6086
+ archive.directory(absoluteOutDir, ignoreBase ? false : import_node_path.default.basename(outDir2));
6085
6087
  archive.finalize();
6086
6088
  } catch (error) {
6087
6089
  Log.error("Error compressing the directory", error);
@@ -6158,7 +6160,7 @@ ${versionInfo}`;
6158
6160
  }
6159
6161
  async function generateVersion(options, mode) {
6160
6162
  const pkg = await (0, import_local_pkg.getPackageInfo)(import_node_process3.default.cwd());
6161
- return `console.info("Version: %c${pkg?.version}%c - ${mode === "serve" ? "runtime" : "built"} on %c${options.date}%c", "color: green;", '', "color: blue;", '')`;
6163
+ return `console.info("Version: %c${pkg?.version}%c - ${mode === "serve" ? "runtime" : "built"} on %c${options.datetime}%c", "color: green;", '', "color: blue;", '')`;
6162
6164
  }
6163
6165
  async function findFolder(directoryPath, dir) {
6164
6166
  const ignore = /* @__PURE__ */ new Set(["dist", "node_modules", "playground", "example", "test", "jest", "tests", "locales", "public", ".git", ".github", ".vscode"]);
@@ -6193,8 +6195,7 @@ function resolveOptions(options) {
6193
6195
  build: /prod/i
6194
6196
  },
6195
6197
  compress: {
6196
- outDir: "dist",
6197
- ignoreBase: true
6198
+ ignoreBase: false
6198
6199
  }
6199
6200
  };
6200
6201
  const mergeOptions = (0, import_utils.deepMerge)(defaults, options);
@@ -6204,7 +6205,7 @@ function resolveOptions(options) {
6204
6205
  });
6205
6206
  return {
6206
6207
  ...mergeOptions,
6207
- date: formatter.format(/* @__PURE__ */ new Date())
6208
+ datetime: formatter.format(/* @__PURE__ */ new Date())
6208
6209
  };
6209
6210
  }
6210
6211
 
@@ -6212,6 +6213,7 @@ function resolveOptions(options) {
6212
6213
  var virtualEnvId = "virtual:env";
6213
6214
  var resolvedVirtualEnvId = `\0${virtualEnvId}`;
6214
6215
  var base = "";
6216
+ var outDir = "";
6215
6217
  var unpluginFactory = (options = {}) => {
6216
6218
  const resolved = resolveOptions(options);
6217
6219
  return [{
@@ -6219,6 +6221,7 @@ var unpluginFactory = (options = {}) => {
6219
6221
  apply: "serve",
6220
6222
  enforce: "post",
6221
6223
  configResolved(config) {
6224
+ outDir = config.build.outDir;
6222
6225
  base = config.base;
6223
6226
  },
6224
6227
  async resolveId(id) {
@@ -6240,6 +6243,7 @@ var unpluginFactory = (options = {}) => {
6240
6243
  enforce: "post",
6241
6244
  configResolved(config) {
6242
6245
  base = config.base;
6246
+ outDir = config.build.outDir;
6243
6247
  },
6244
6248
  resolveId(id) {
6245
6249
  if (id.startsWith(virtualEnvId))
@@ -6263,7 +6267,7 @@ var unpluginFactory = (options = {}) => {
6263
6267
  buildEnd: () => {
6264
6268
  import_node_process4.default.on("beforeExit", async () => {
6265
6269
  const { compress } = resolved;
6266
- await createCompress(compress);
6270
+ await createCompress(compress, outDir);
6267
6271
  import_node_process4.default.exit(0);
6268
6272
  });
6269
6273
  }
package/dist/vite.js CHANGED
@@ -5,8 +5,8 @@
5
5
 
6
6
  import {
7
7
  vite_default
8
- } from "./chunk-Y45ERLIW.js";
9
- import "./chunk-QWCQIGEO.js";
8
+ } from "./chunk-6I6MSMXF.js";
9
+ import "./chunk-V2T5VQQ7.js";
10
10
  export {
11
11
  vite_default as default
12
12
  };
package/dist/webpack.cjs CHANGED
@@ -6057,16 +6057,18 @@ var Log = class {
6057
6057
  };
6058
6058
 
6059
6059
  // src/core/compress.ts
6060
- async function createCompress(options) {
6061
- const { outDir, ignoreBase } = options;
6062
- const zipFilePath = import_node_path.default.resolve(import_node_process2.default.cwd(), `${import_node_path.default.basename(outDir)}.zip`);
6063
- Log.log("Compressing the directory", outDir);
6060
+ async function createCompress(options, outDir2) {
6061
+ const { ignoreBase } = options;
6062
+ const zipFilePath = import_node_path.default.resolve(import_node_process2.default.cwd(), `${import_node_path.default.basename(outDir2)}.zip`);
6063
+ Log.log("Compressing the directory", outDir2);
6064
6064
  return new Promise((resolve, reject) => {
6065
6065
  try {
6066
6066
  const output = import_node_fs.default.createWriteStream(zipFilePath);
6067
6067
  const archive = (0, import_archiver.default)("zip");
6068
6068
  output.on("close", () => {
6069
- Log.success("Successfully compressed to", `${zipFilePath} (${(archive.pointer() / 1024 / 1024).toFixed(1)} MB)`);
6069
+ const size = archive.pointer();
6070
+ const sizeInMB = size > 1024 * 1024 ? `${(size / 1024 / 1024).toFixed(1)} MB` : `${(size / 1024).toFixed(1)} KB`;
6071
+ Log.success("Successfully compressed to", `${zipFilePath} (${sizeInMB})`);
6070
6072
  resolve(null);
6071
6073
  });
6072
6074
  archive.on("warning", (err) => {
@@ -6080,8 +6082,8 @@ async function createCompress(options) {
6080
6082
  reject(err);
6081
6083
  });
6082
6084
  archive.pipe(output);
6083
- const absoluteOutDir = import_node_path.default.resolve(outDir);
6084
- archive.directory(absoluteOutDir, ignoreBase ? false : import_node_path.default.basename(outDir));
6085
+ const absoluteOutDir = import_node_path.default.resolve(outDir2);
6086
+ archive.directory(absoluteOutDir, ignoreBase ? false : import_node_path.default.basename(outDir2));
6085
6087
  archive.finalize();
6086
6088
  } catch (error) {
6087
6089
  Log.error("Error compressing the directory", error);
@@ -6158,7 +6160,7 @@ ${versionInfo}`;
6158
6160
  }
6159
6161
  async function generateVersion(options, mode) {
6160
6162
  const pkg = await (0, import_local_pkg.getPackageInfo)(import_node_process3.default.cwd());
6161
- return `console.info("Version: %c${pkg?.version}%c - ${mode === "serve" ? "runtime" : "built"} on %c${options.date}%c", "color: green;", '', "color: blue;", '')`;
6163
+ return `console.info("Version: %c${pkg?.version}%c - ${mode === "serve" ? "runtime" : "built"} on %c${options.datetime}%c", "color: green;", '', "color: blue;", '')`;
6162
6164
  }
6163
6165
  async function findFolder(directoryPath, dir) {
6164
6166
  const ignore = /* @__PURE__ */ new Set(["dist", "node_modules", "playground", "example", "test", "jest", "tests", "locales", "public", ".git", ".github", ".vscode"]);
@@ -6193,8 +6195,7 @@ function resolveOptions(options) {
6193
6195
  build: /prod/i
6194
6196
  },
6195
6197
  compress: {
6196
- outDir: "dist",
6197
- ignoreBase: true
6198
+ ignoreBase: false
6198
6199
  }
6199
6200
  };
6200
6201
  const mergeOptions = (0, import_utils.deepMerge)(defaults, options);
@@ -6204,7 +6205,7 @@ function resolveOptions(options) {
6204
6205
  });
6205
6206
  return {
6206
6207
  ...mergeOptions,
6207
- date: formatter.format(/* @__PURE__ */ new Date())
6208
+ datetime: formatter.format(/* @__PURE__ */ new Date())
6208
6209
  };
6209
6210
  }
6210
6211
 
@@ -6212,6 +6213,7 @@ function resolveOptions(options) {
6212
6213
  var virtualEnvId = "virtual:env";
6213
6214
  var resolvedVirtualEnvId = `\0${virtualEnvId}`;
6214
6215
  var base = "";
6216
+ var outDir = "";
6215
6217
  var unpluginFactory = (options = {}) => {
6216
6218
  const resolved = resolveOptions(options);
6217
6219
  return [{
@@ -6219,6 +6221,7 @@ var unpluginFactory = (options = {}) => {
6219
6221
  apply: "serve",
6220
6222
  enforce: "post",
6221
6223
  configResolved(config) {
6224
+ outDir = config.build.outDir;
6222
6225
  base = config.base;
6223
6226
  },
6224
6227
  async resolveId(id) {
@@ -6240,6 +6243,7 @@ var unpluginFactory = (options = {}) => {
6240
6243
  enforce: "post",
6241
6244
  configResolved(config) {
6242
6245
  base = config.base;
6246
+ outDir = config.build.outDir;
6243
6247
  },
6244
6248
  resolveId(id) {
6245
6249
  if (id.startsWith(virtualEnvId))
@@ -6263,7 +6267,7 @@ var unpluginFactory = (options = {}) => {
6263
6267
  buildEnd: () => {
6264
6268
  import_node_process4.default.on("beforeExit", async () => {
6265
6269
  const { compress } = resolved;
6266
- await createCompress(compress);
6270
+ await createCompress(compress, outDir);
6267
6271
  import_node_process4.default.exit(0);
6268
6272
  });
6269
6273
  }
package/dist/webpack.js CHANGED
@@ -5,8 +5,8 @@
5
5
 
6
6
  import {
7
7
  webpack_default
8
- } from "./chunk-ELYQVJHH.js";
9
- import "./chunk-QWCQIGEO.js";
8
+ } from "./chunk-664Z6SFJ.js";
9
+ import "./chunk-V2T5VQQ7.js";
10
10
  export {
11
11
  webpack_default as default
12
12
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unplugin-env",
3
3
  "type": "module",
4
- "version": "1.0.1",
4
+ "version": "1.0.2",
5
5
  "packageManager": "pnpm@9.15.4",
6
6
  "description": "Register global imports on demand for Vite and Webpack",
7
7
  "license": "MIT",