unplugin-env 1.0.1 → 1.0.3
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 +3 -0
- package/README.zh-CN.md +3 -0
- package/dist/{chunk-ELYQVJHH.js → chunk-3MY5IADX.js} +1 -1
- package/dist/{chunk-Y45ERLIW.js → chunk-7PNJWMAM.js} +1 -1
- package/dist/{chunk-QWCQIGEO.js → chunk-IQADAXMX.js} +201 -111
- package/dist/esbuild.cjs +201 -111
- package/dist/esbuild.js +1 -1
- package/dist/index.cjs +201 -111
- package/dist/index.js +1 -1
- package/dist/nuxt.cjs +201 -111
- package/dist/nuxt.js +3 -3
- package/dist/rollup.cjs +201 -111
- package/dist/rollup.js +1 -1
- package/dist/types.d.cts +1 -2
- package/dist/types.d.ts +1 -2
- package/dist/vite.cjs +201 -111
- package/dist/vite.js +2 -2
- package/dist/webpack.cjs +201 -111
- package/dist/webpack.js +2 -2
- package/package.json +3 -3
package/dist/rollup.cjs
CHANGED
|
@@ -1914,7 +1914,7 @@ var require_scan = __commonJS({
|
|
|
1914
1914
|
isExtglob = false;
|
|
1915
1915
|
isGlob = false;
|
|
1916
1916
|
}
|
|
1917
|
-
let
|
|
1917
|
+
let base = str;
|
|
1918
1918
|
let prefix = "";
|
|
1919
1919
|
let glob = "";
|
|
1920
1920
|
if (start > 0) {
|
|
@@ -1922,31 +1922,31 @@ var require_scan = __commonJS({
|
|
|
1922
1922
|
str = str.slice(start);
|
|
1923
1923
|
lastIndex -= start;
|
|
1924
1924
|
}
|
|
1925
|
-
if (
|
|
1926
|
-
|
|
1925
|
+
if (base && isGlob === true && lastIndex > 0) {
|
|
1926
|
+
base = str.slice(0, lastIndex);
|
|
1927
1927
|
glob = str.slice(lastIndex);
|
|
1928
1928
|
} else if (isGlob === true) {
|
|
1929
|
-
|
|
1929
|
+
base = "";
|
|
1930
1930
|
glob = str;
|
|
1931
1931
|
} else {
|
|
1932
|
-
|
|
1932
|
+
base = str;
|
|
1933
1933
|
}
|
|
1934
|
-
if (
|
|
1935
|
-
if (isPathSeparator(
|
|
1936
|
-
|
|
1934
|
+
if (base && base !== "" && base !== "/" && base !== str) {
|
|
1935
|
+
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
|
1936
|
+
base = base.slice(0, -1);
|
|
1937
1937
|
}
|
|
1938
1938
|
}
|
|
1939
1939
|
if (opts.unescape === true) {
|
|
1940
1940
|
if (glob) glob = utils.removeBackslashes(glob);
|
|
1941
|
-
if (
|
|
1942
|
-
|
|
1941
|
+
if (base && backslashes === true) {
|
|
1942
|
+
base = utils.removeBackslashes(base);
|
|
1943
1943
|
}
|
|
1944
1944
|
}
|
|
1945
1945
|
const state = {
|
|
1946
1946
|
prefix,
|
|
1947
1947
|
input,
|
|
1948
1948
|
start,
|
|
1949
|
-
base
|
|
1949
|
+
base,
|
|
1950
1950
|
glob,
|
|
1951
1951
|
isBrace,
|
|
1952
1952
|
isBracket,
|
|
@@ -3499,28 +3499,28 @@ var require_tasks = __commonJS({
|
|
|
3499
3499
|
function groupPatternsByBaseDirectory(patterns) {
|
|
3500
3500
|
const group = {};
|
|
3501
3501
|
return patterns.reduce((collection, pattern) => {
|
|
3502
|
-
const
|
|
3503
|
-
if (
|
|
3504
|
-
collection[
|
|
3502
|
+
const base = utils.pattern.getBaseDirectory(pattern);
|
|
3503
|
+
if (base in collection) {
|
|
3504
|
+
collection[base].push(pattern);
|
|
3505
3505
|
} else {
|
|
3506
|
-
collection[
|
|
3506
|
+
collection[base] = [pattern];
|
|
3507
3507
|
}
|
|
3508
3508
|
return collection;
|
|
3509
3509
|
}, group);
|
|
3510
3510
|
}
|
|
3511
3511
|
exports2.groupPatternsByBaseDirectory = groupPatternsByBaseDirectory;
|
|
3512
3512
|
function convertPatternGroupsToTasks(positive, negative, dynamic) {
|
|
3513
|
-
return Object.keys(positive).map((
|
|
3514
|
-
return convertPatternGroupToTask(
|
|
3513
|
+
return Object.keys(positive).map((base) => {
|
|
3514
|
+
return convertPatternGroupToTask(base, positive[base], negative, dynamic);
|
|
3515
3515
|
});
|
|
3516
3516
|
}
|
|
3517
3517
|
exports2.convertPatternGroupsToTasks = convertPatternGroupsToTasks;
|
|
3518
|
-
function convertPatternGroupToTask(
|
|
3518
|
+
function convertPatternGroupToTask(base, positive, negative, dynamic) {
|
|
3519
3519
|
return {
|
|
3520
3520
|
dynamic,
|
|
3521
3521
|
positive,
|
|
3522
3522
|
negative,
|
|
3523
|
-
base
|
|
3523
|
+
base,
|
|
3524
3524
|
patterns: [].concat(positive, negative.map(utils.pattern.convertToNegativePattern))
|
|
3525
3525
|
};
|
|
3526
3526
|
}
|
|
@@ -4460,8 +4460,8 @@ var require_async3 = __commonJS({
|
|
|
4460
4460
|
onEnd(callback) {
|
|
4461
4461
|
this._emitter.once("end", callback);
|
|
4462
4462
|
}
|
|
4463
|
-
_pushToQueue(directory,
|
|
4464
|
-
const queueItem = { directory, base
|
|
4463
|
+
_pushToQueue(directory, base) {
|
|
4464
|
+
const queueItem = { directory, base };
|
|
4465
4465
|
this._queue.push(queueItem, (error) => {
|
|
4466
4466
|
if (error !== null) {
|
|
4467
4467
|
this._handleError(error);
|
|
@@ -4488,19 +4488,19 @@ var require_async3 = __commonJS({
|
|
|
4488
4488
|
this._isDestroyed = true;
|
|
4489
4489
|
this._emitter.emit("error", error);
|
|
4490
4490
|
}
|
|
4491
|
-
_handleEntry(entry,
|
|
4491
|
+
_handleEntry(entry, base) {
|
|
4492
4492
|
if (this._isDestroyed || this._isFatalError) {
|
|
4493
4493
|
return;
|
|
4494
4494
|
}
|
|
4495
4495
|
const fullpath = entry.path;
|
|
4496
|
-
if (
|
|
4497
|
-
entry.path = common.joinPathSegments(
|
|
4496
|
+
if (base !== void 0) {
|
|
4497
|
+
entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator);
|
|
4498
4498
|
}
|
|
4499
4499
|
if (common.isAppliedFilter(this._settings.entryFilter, entry)) {
|
|
4500
4500
|
this._emitEntry(entry);
|
|
4501
4501
|
}
|
|
4502
4502
|
if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) {
|
|
4503
|
-
this._pushToQueue(fullpath,
|
|
4503
|
+
this._pushToQueue(fullpath, base === void 0 ? void 0 : entry.path);
|
|
4504
4504
|
}
|
|
4505
4505
|
}
|
|
4506
4506
|
_emitEntry(entry) {
|
|
@@ -4608,19 +4608,19 @@ var require_sync3 = __commonJS({
|
|
|
4608
4608
|
this._handleQueue();
|
|
4609
4609
|
return this._storage;
|
|
4610
4610
|
}
|
|
4611
|
-
_pushToQueue(directory,
|
|
4612
|
-
this._queue.add({ directory, base
|
|
4611
|
+
_pushToQueue(directory, base) {
|
|
4612
|
+
this._queue.add({ directory, base });
|
|
4613
4613
|
}
|
|
4614
4614
|
_handleQueue() {
|
|
4615
4615
|
for (const item of this._queue.values()) {
|
|
4616
4616
|
this._handleDirectory(item.directory, item.base);
|
|
4617
4617
|
}
|
|
4618
4618
|
}
|
|
4619
|
-
_handleDirectory(directory,
|
|
4619
|
+
_handleDirectory(directory, base) {
|
|
4620
4620
|
try {
|
|
4621
4621
|
const entries = this._scandir(directory, this._settings.fsScandirSettings);
|
|
4622
4622
|
for (const entry of entries) {
|
|
4623
|
-
this._handleEntry(entry,
|
|
4623
|
+
this._handleEntry(entry, base);
|
|
4624
4624
|
}
|
|
4625
4625
|
} catch (error) {
|
|
4626
4626
|
this._handleError(error);
|
|
@@ -4632,16 +4632,16 @@ var require_sync3 = __commonJS({
|
|
|
4632
4632
|
}
|
|
4633
4633
|
throw error;
|
|
4634
4634
|
}
|
|
4635
|
-
_handleEntry(entry,
|
|
4635
|
+
_handleEntry(entry, base) {
|
|
4636
4636
|
const fullpath = entry.path;
|
|
4637
|
-
if (
|
|
4638
|
-
entry.path = common.joinPathSegments(
|
|
4637
|
+
if (base !== void 0) {
|
|
4638
|
+
entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator);
|
|
4639
4639
|
}
|
|
4640
4640
|
if (common.isAppliedFilter(this._settings.entryFilter, entry)) {
|
|
4641
4641
|
this._pushToStorage(entry);
|
|
4642
4642
|
}
|
|
4643
4643
|
if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) {
|
|
4644
|
-
this._pushToQueue(fullpath,
|
|
4644
|
+
this._pushToQueue(fullpath, base === void 0 ? void 0 : entry.path);
|
|
4645
4645
|
}
|
|
4646
4646
|
}
|
|
4647
4647
|
_pushToStorage(entry) {
|
|
@@ -5538,14 +5538,14 @@ var import_unplugin2 = require("unplugin");
|
|
|
5538
5538
|
|
|
5539
5539
|
// src/index.ts
|
|
5540
5540
|
var import_node_fs3 = require("fs");
|
|
5541
|
-
var
|
|
5541
|
+
var import_node_process5 = __toESM(require("process"), 1);
|
|
5542
5542
|
var import_unplugin = require("unplugin");
|
|
5543
5543
|
|
|
5544
5544
|
// src/core/compress.ts
|
|
5545
5545
|
var import_node_fs = __toESM(require("fs"), 1);
|
|
5546
5546
|
var import_node_path = __toESM(require("path"), 1);
|
|
5547
5547
|
var import_node_process2 = __toESM(require("process"), 1);
|
|
5548
|
-
var
|
|
5548
|
+
var import_zip_lib = require("zip-lib");
|
|
5549
5549
|
|
|
5550
5550
|
// node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
5551
5551
|
var ANSI_BACKGROUND_OFFSET = 10;
|
|
@@ -6057,39 +6057,37 @@ var Log = class {
|
|
|
6057
6057
|
};
|
|
6058
6058
|
|
|
6059
6059
|
// src/core/compress.ts
|
|
6060
|
-
async function createCompress(options) {
|
|
6061
|
-
const {
|
|
6060
|
+
async function createCompress(options, outDir) {
|
|
6061
|
+
const { ignoreBase } = options;
|
|
6062
6062
|
const zipFilePath = import_node_path.default.resolve(import_node_process2.default.cwd(), `${import_node_path.default.basename(outDir)}.zip`);
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
|
|
6069
|
-
|
|
6070
|
-
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
archive.finalize();
|
|
6086
|
-
} catch (error) {
|
|
6087
|
-
Log.error("Error compressing the directory", error);
|
|
6088
|
-
throw error;
|
|
6089
|
-
}
|
|
6090
|
-
});
|
|
6063
|
+
const absoluteOutDir = import_node_path.default.resolve(outDir);
|
|
6064
|
+
Log.log("Compressing directory:", absoluteOutDir);
|
|
6065
|
+
try {
|
|
6066
|
+
const zip = new import_zip_lib.Zip();
|
|
6067
|
+
if (ignoreBase) {
|
|
6068
|
+
zip.addFolder(absoluteOutDir);
|
|
6069
|
+
} else {
|
|
6070
|
+
zip.addFolder(absoluteOutDir, import_node_path.default.basename(outDir));
|
|
6071
|
+
}
|
|
6072
|
+
await zip.archive(zipFilePath);
|
|
6073
|
+
const stat = import_node_fs.default.statSync(zipFilePath);
|
|
6074
|
+
const size = stat.size;
|
|
6075
|
+
const readableSize = size > 1024 * 1024 ? `${(size / 1024 / 1024).toFixed(1)} MB` : `${(size / 1024).toFixed(1)} KB`;
|
|
6076
|
+
Log.success(
|
|
6077
|
+
"Successfully compressed to:",
|
|
6078
|
+
`${zipFilePath} (${readableSize})`
|
|
6079
|
+
);
|
|
6080
|
+
return null;
|
|
6081
|
+
} catch (error) {
|
|
6082
|
+
Log.error("Compression error:", error);
|
|
6083
|
+
throw error;
|
|
6084
|
+
}
|
|
6091
6085
|
}
|
|
6092
6086
|
|
|
6087
|
+
// src/core/options.ts
|
|
6088
|
+
var import_node_process4 = __toESM(require("process"), 1);
|
|
6089
|
+
var import_utils = require("@antfu/utils");
|
|
6090
|
+
|
|
6093
6091
|
// src/core/generate.ts
|
|
6094
6092
|
var import_node_fs2 = require("fs");
|
|
6095
6093
|
var import_node_path2 = __toESM(require("path"), 1);
|
|
@@ -6110,14 +6108,15 @@ function mergeObjects(prodObj, devObj) {
|
|
|
6110
6108
|
}
|
|
6111
6109
|
}
|
|
6112
6110
|
}
|
|
6113
|
-
async function generateScript(options,
|
|
6111
|
+
async function generateScript(options, context) {
|
|
6114
6112
|
const { dir, fileName, globalName, serve, build } = options.env;
|
|
6115
6113
|
const folder = await findFolder(import_node_process3.default.cwd(), dir);
|
|
6116
6114
|
const files = await (0, import_fast_glob.default)("*.+(js|ts)", {
|
|
6117
6115
|
absolute: true,
|
|
6118
6116
|
cwd: folder
|
|
6119
6117
|
});
|
|
6120
|
-
const
|
|
6118
|
+
const { mode, base } = context;
|
|
6119
|
+
const testReg = mode === "dev" ? serve : build;
|
|
6121
6120
|
let target = "";
|
|
6122
6121
|
let source = "";
|
|
6123
6122
|
let code = "";
|
|
@@ -6146,7 +6145,7 @@ ${versionInfo}`;
|
|
|
6146
6145
|
const formatCode = code;
|
|
6147
6146
|
return {
|
|
6148
6147
|
code,
|
|
6149
|
-
script: ` <script type="text/javascript" src="${
|
|
6148
|
+
script: ` <script type="text/javascript" src="${base}${fileName}"></script>
|
|
6150
6149
|
</head>`,
|
|
6151
6150
|
emit: {
|
|
6152
6151
|
type: "asset",
|
|
@@ -6158,7 +6157,7 @@ ${versionInfo}`;
|
|
|
6158
6157
|
}
|
|
6159
6158
|
async function generateVersion(options, mode) {
|
|
6160
6159
|
const pkg = await (0, import_local_pkg.getPackageInfo)(import_node_process3.default.cwd());
|
|
6161
|
-
return `console.info("Version: %c${pkg?.version}%c - ${mode === "
|
|
6160
|
+
return `console.info("Version: %c${pkg?.version}%c - ${mode === "dev" ? "runtime" : "built"} on %c${options.datetime}%c", "color: green;", '', "color: blue;", '')`;
|
|
6162
6161
|
}
|
|
6163
6162
|
async function findFolder(directoryPath, dir) {
|
|
6164
6163
|
const ignore = /* @__PURE__ */ new Set(["dist", "node_modules", "playground", "example", "test", "jest", "tests", "locales", "public", ".git", ".github", ".vscode"]);
|
|
@@ -6182,7 +6181,6 @@ async function findFolder(directoryPath, dir) {
|
|
|
6182
6181
|
}
|
|
6183
6182
|
|
|
6184
6183
|
// src/core/options.ts
|
|
6185
|
-
var import_utils = require("@antfu/utils");
|
|
6186
6184
|
function resolveOptions(options) {
|
|
6187
6185
|
const defaults = {
|
|
6188
6186
|
env: {
|
|
@@ -6193,8 +6191,7 @@ function resolveOptions(options) {
|
|
|
6193
6191
|
build: /prod/i
|
|
6194
6192
|
},
|
|
6195
6193
|
compress: {
|
|
6196
|
-
|
|
6197
|
-
ignoreBase: true
|
|
6194
|
+
ignoreBase: false
|
|
6198
6195
|
}
|
|
6199
6196
|
};
|
|
6200
6197
|
const mergeOptions = (0, import_utils.deepMerge)(defaults, options);
|
|
@@ -6204,67 +6201,160 @@ function resolveOptions(options) {
|
|
|
6204
6201
|
});
|
|
6205
6202
|
return {
|
|
6206
6203
|
...mergeOptions,
|
|
6207
|
-
|
|
6204
|
+
datetime: formatter.format(/* @__PURE__ */ new Date())
|
|
6208
6205
|
};
|
|
6209
6206
|
}
|
|
6207
|
+
function createUnifiedContext(resolved) {
|
|
6208
|
+
const ctx = {
|
|
6209
|
+
framework: "",
|
|
6210
|
+
base: "/",
|
|
6211
|
+
outDir: "dist",
|
|
6212
|
+
mode: "build",
|
|
6213
|
+
scriptInfo: {
|
|
6214
|
+
code: "",
|
|
6215
|
+
script: "",
|
|
6216
|
+
emit: {
|
|
6217
|
+
type: "asset",
|
|
6218
|
+
source: "",
|
|
6219
|
+
fileName: ""
|
|
6220
|
+
},
|
|
6221
|
+
watchFiles: []
|
|
6222
|
+
},
|
|
6223
|
+
get isDev() {
|
|
6224
|
+
return this.mode === "dev";
|
|
6225
|
+
},
|
|
6226
|
+
get isBuild() {
|
|
6227
|
+
return this.mode === "build";
|
|
6228
|
+
},
|
|
6229
|
+
// --- VITE ---
|
|
6230
|
+
async setVite(config) {
|
|
6231
|
+
this.framework = "vite";
|
|
6232
|
+
this.base = config.base || "/";
|
|
6233
|
+
this.outDir = config.build?.outDir || "dist";
|
|
6234
|
+
this.mode = config.command === "serve" ? "dev" : "build";
|
|
6235
|
+
ctx.scriptInfo = await generateScript(resolved, ctx);
|
|
6236
|
+
},
|
|
6237
|
+
// --- ROLLUP ---
|
|
6238
|
+
async setRollup(options) {
|
|
6239
|
+
this.framework = "rollup";
|
|
6240
|
+
this.outDir = options.dir || "dist";
|
|
6241
|
+
this.mode = import_node_process4.default.env.ROLLUP_WATCH ? "dev" : "build";
|
|
6242
|
+
ctx.scriptInfo = await generateScript(resolved, ctx);
|
|
6243
|
+
},
|
|
6244
|
+
// --- WEBPACK ---
|
|
6245
|
+
async setWebpack(compiler) {
|
|
6246
|
+
this.framework = "webpack";
|
|
6247
|
+
this.base = compiler.options.output?.publicPath || "/";
|
|
6248
|
+
this.outDir = compiler.options.output?.path || "dist";
|
|
6249
|
+
const raw = compiler.options.mode || "production";
|
|
6250
|
+
this.mode = raw === "development" ? "dev" : "build";
|
|
6251
|
+
ctx.scriptInfo = await generateScript(resolved, ctx);
|
|
6252
|
+
},
|
|
6253
|
+
// --- RSPACK ---
|
|
6254
|
+
async setRspack(compiler) {
|
|
6255
|
+
this.framework = "rspack";
|
|
6256
|
+
this.base = compiler.options.output?.publicPath || "/";
|
|
6257
|
+
this.outDir = compiler.options.output?.path || "dist";
|
|
6258
|
+
const raw = compiler.options.mode || "production";
|
|
6259
|
+
this.mode = raw === "development" ? "dev" : "build";
|
|
6260
|
+
ctx.scriptInfo = await generateScript(resolved, ctx);
|
|
6261
|
+
},
|
|
6262
|
+
// --- ESBUILD ---
|
|
6263
|
+
async setEsbuild(build) {
|
|
6264
|
+
this.framework = "esbuild";
|
|
6265
|
+
this.outDir = build.initialOptions.outdir || "dist";
|
|
6266
|
+
this.mode = build.initialOptions.watch ? "dev" : "build";
|
|
6267
|
+
ctx.scriptInfo = await generateScript(resolved, ctx);
|
|
6268
|
+
},
|
|
6269
|
+
// --- FARM ---
|
|
6270
|
+
async setFarm(compiler) {
|
|
6271
|
+
this.framework = "farm";
|
|
6272
|
+
this.base = compiler.config.output?.publicPath || "/";
|
|
6273
|
+
this.outDir = compiler.config.output?.path || "dist";
|
|
6274
|
+
const raw = compiler.config.mode || "production";
|
|
6275
|
+
this.mode = raw === "development" ? "dev" : "build";
|
|
6276
|
+
ctx.scriptInfo = await generateScript(resolved, ctx);
|
|
6277
|
+
},
|
|
6278
|
+
// --- ROLLDOWN ---
|
|
6279
|
+
async setRolldown(options) {
|
|
6280
|
+
this.framework = "rolldown";
|
|
6281
|
+
this.outDir = options.dir || "dist";
|
|
6282
|
+
this.mode = import_node_process4.default.env.ROLLDOWN_WATCH ? "dev" : "build";
|
|
6283
|
+
ctx.scriptInfo = await generateScript(resolved, ctx);
|
|
6284
|
+
}
|
|
6285
|
+
};
|
|
6286
|
+
return ctx;
|
|
6287
|
+
}
|
|
6210
6288
|
|
|
6211
6289
|
// src/index.ts
|
|
6212
6290
|
var virtualEnvId = "virtual:env";
|
|
6213
6291
|
var resolvedVirtualEnvId = `\0${virtualEnvId}`;
|
|
6214
|
-
var base = "";
|
|
6215
6292
|
var unpluginFactory = (options = {}) => {
|
|
6216
6293
|
const resolved = resolveOptions(options);
|
|
6294
|
+
const ctx = createUnifiedContext(resolved);
|
|
6217
6295
|
return [{
|
|
6218
|
-
name: "plugin-env
|
|
6219
|
-
apply: "serve",
|
|
6296
|
+
name: "plugin-env",
|
|
6220
6297
|
enforce: "post",
|
|
6221
|
-
|
|
6222
|
-
|
|
6298
|
+
rollup: {
|
|
6299
|
+
outputOptions(outputOptions) {
|
|
6300
|
+
ctx.setRollup(outputOptions);
|
|
6301
|
+
return outputOptions;
|
|
6302
|
+
}
|
|
6223
6303
|
},
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6304
|
+
vite: {
|
|
6305
|
+
async configResolved(config) {
|
|
6306
|
+
await ctx.setVite(config);
|
|
6307
|
+
}
|
|
6227
6308
|
},
|
|
6228
|
-
async
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6309
|
+
async webpack(compiler) {
|
|
6310
|
+
await ctx.setWebpack(compiler);
|
|
6311
|
+
},
|
|
6312
|
+
rspack: async (compiler) => {
|
|
6313
|
+
await ctx.setRspack(compiler);
|
|
6314
|
+
},
|
|
6315
|
+
esbuild: {
|
|
6316
|
+
async setup(build) {
|
|
6317
|
+
await ctx.setEsbuild(build);
|
|
6235
6318
|
}
|
|
6236
|
-
}
|
|
6237
|
-
}, {
|
|
6238
|
-
name: "unplugin-env-build",
|
|
6239
|
-
apply: "build",
|
|
6240
|
-
enforce: "post",
|
|
6241
|
-
configResolved(config) {
|
|
6242
|
-
base = config.base;
|
|
6243
6319
|
},
|
|
6244
|
-
|
|
6320
|
+
async farm(compiler) {
|
|
6321
|
+
await ctx.setFarm(compiler);
|
|
6322
|
+
},
|
|
6323
|
+
rolldown: {
|
|
6324
|
+
async outputOptions(outputOptions) {
|
|
6325
|
+
await ctx.setRolldown(outputOptions);
|
|
6326
|
+
}
|
|
6327
|
+
},
|
|
6328
|
+
async resolveId(id) {
|
|
6245
6329
|
if (id.startsWith(virtualEnvId))
|
|
6246
6330
|
return resolvedVirtualEnvId;
|
|
6247
6331
|
},
|
|
6248
6332
|
async load(id) {
|
|
6249
|
-
const { emit, script } =
|
|
6250
|
-
if (
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6333
|
+
const { code, watchFiles, emit, script } = ctx.scriptInfo;
|
|
6334
|
+
if (ctx.isDev) {
|
|
6335
|
+
if (id.startsWith(resolvedVirtualEnvId)) {
|
|
6336
|
+
watchFiles.forEach((file) => {
|
|
6337
|
+
this.addWatchFile(file);
|
|
6338
|
+
});
|
|
6339
|
+
return code;
|
|
6340
|
+
}
|
|
6341
|
+
} else {
|
|
6342
|
+
if (id.startsWith(resolvedVirtualEnvId)) {
|
|
6343
|
+
this.emitFile(emit);
|
|
6344
|
+
return "";
|
|
6345
|
+
}
|
|
6346
|
+
if (id.endsWith(".html")) {
|
|
6347
|
+
let code2 = await import_node_fs3.promises.readFile(id, "utf-8");
|
|
6348
|
+
code2 = code2.replace(/<\/head>/g, script);
|
|
6349
|
+
return { code: code2 };
|
|
6350
|
+
}
|
|
6260
6351
|
}
|
|
6261
|
-
return null;
|
|
6262
6352
|
},
|
|
6263
6353
|
buildEnd: () => {
|
|
6264
|
-
|
|
6354
|
+
import_node_process5.default.on("beforeExit", async () => {
|
|
6265
6355
|
const { compress } = resolved;
|
|
6266
|
-
await createCompress(compress);
|
|
6267
|
-
|
|
6356
|
+
await createCompress(compress, ctx.outDir);
|
|
6357
|
+
import_node_process5.default.exit(0);
|
|
6268
6358
|
});
|
|
6269
6359
|
}
|
|
6270
6360
|
}];
|
package/dist/rollup.js
CHANGED
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
|
-
|
|
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
|
-
|
|
37
|
+
datetime: string;
|
|
39
38
|
};
|
|
40
39
|
interface GenerateScript {
|
|
41
40
|
code: string;
|