fix(config): update .smartconfig.json handling and harden bundler runtime compatibility

This commit is contained in:
2026-05-09 12:34:00 +00:00
parent f19c7c69af
commit e5b2f2ba30
18 changed files with 2712 additions and 3190 deletions
+13 -15
View File
@@ -21,30 +21,28 @@ export class HtmlHandler {
to?: string;
minify?: boolean;
}) {
optionsArg = {
...{
from: this.defaultFromPath,
to: this.defaultToPath,
minify: false,
},
const options = {
from: this.defaultFromPath,
to: this.defaultToPath,
minify: false,
...optionsArg,
};
if (await this.checkIfExists()) {
console.log(`${optionsArg.from} replaces file at ${optionsArg.to}`);
console.log(`${options.from} replaces file at ${options.to}`);
}
optionsArg.from = plugins.smartpath.transform.toAbsolute(
optionsArg.from,
options.from = plugins.smartpath.transform.toAbsolute(
options.from,
paths.cwd,
) as string;
optionsArg.to = plugins.smartpath.transform.toAbsolute(
optionsArg.to,
options.to = plugins.smartpath.transform.toAbsolute(
options.to,
paths.cwd,
) as string;
let fileString = (await plugins.fs
.file(optionsArg.from)
.file(options.from)
.encoding('utf8')
.read()) as string;
if (optionsArg.minify) {
if (options.minify) {
fileString = plugins.htmlMinifier.minify(fileString, {
minifyCSS: true,
minifyJS: true,
@@ -56,9 +54,9 @@ export class HtmlHandler {
removeComments: true,
});
}
const toDir = plugins.path.dirname(optionsArg.to);
const toDir = plugins.path.dirname(options.to);
await plugins.fs.directory(toDir).create();
await plugins.fs.file(optionsArg.to).encoding('utf8').write(fileString);
await plugins.fs.file(options.to).encoding('utf8').write(fileString);
console.log(`html processing succeeded!`);
}
}