fix(core): update
This commit is contained in:
parent
6dcb3f7c2a
commit
f3b50d384a
5195
package-lock.json
generated
5195
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
14
package.json
14
package.json
@ -17,24 +17,24 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.63",
|
||||
"@gitzone/tsrun": "^1.2.35",
|
||||
"@gitzone/tstest": "^1.0.71",
|
||||
"@pushrocks/tapbundle": "^5.0.3"
|
||||
"@gitzone/tsrun": "^1.2.37",
|
||||
"@gitzone/tstest": "^1.0.72",
|
||||
"@pushrocks/tapbundle": "^5.0.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/early": "^4.0.3",
|
||||
"@pushrocks/smartcli": "^3.0.14",
|
||||
"@pushrocks/smartfile": "^9.0.6",
|
||||
"@pushrocks/smartlog": "^2.0.44",
|
||||
"@pushrocks/smartfile": "^10.0.2",
|
||||
"@pushrocks/smartlog": "^3.0.0",
|
||||
"@pushrocks/smartlog-destination-local": "^8.0.8",
|
||||
"@pushrocks/smartpath": "^5.0.5",
|
||||
"@pushrocks/smartpromise": "^3.1.7",
|
||||
"@pushrocks/smartspawn": "^2.0.9",
|
||||
"@types/html-minifier": "^4.0.2",
|
||||
"@types/node": "^17.0.38",
|
||||
"@types/node": "^18.0.6",
|
||||
"esbuild": "0.14.27",
|
||||
"html-minifier": "^4.0.0",
|
||||
"typescript": "^4.7.2"
|
||||
"typescript": "^4.7.4"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@gitzone/tsbundle',
|
||||
version: '2.0.5',
|
||||
version: '2.0.6',
|
||||
description: 'a bundler using rollup for painless bundling of web projects'
|
||||
}
|
||||
|
@ -10,35 +10,38 @@ export class HtmlHandler {
|
||||
}
|
||||
|
||||
// copies the html
|
||||
public async copyHtml(fromArg: string = this.defaultFromPath, toArg: string = this.defaultToPath) {
|
||||
if (await this.checkIfExists()) {
|
||||
console.log(`${fromArg} replaces file at ${toArg}`);
|
||||
public async processHtml(optionsArg: {
|
||||
from?: string;
|
||||
to?: string;
|
||||
minify?: boolean;
|
||||
}) {
|
||||
optionsArg = {
|
||||
... {
|
||||
from: this.defaultFromPath,
|
||||
to: this.defaultToPath,
|
||||
minify: false,
|
||||
},
|
||||
...optionsArg
|
||||
}
|
||||
fromArg = plugins.smartpath.transform.toAbsolute(fromArg, paths.cwd) as string;
|
||||
toArg = plugins.smartpath.transform.toAbsolute(toArg, paths.cwd) as string;
|
||||
await plugins.smartfile.fs.copy(fromArg, toArg);
|
||||
console.log(`html copy succeeded!`);
|
||||
}
|
||||
|
||||
// copies and minifies the html
|
||||
public async minifyHtml(fromArg: string = this.defaultFromPath, toArg: string = this.defaultToPath) {
|
||||
if (await this.checkIfExists()) {
|
||||
console.log(`${fromArg} replaces file at ${toArg}`);
|
||||
console.log(`${optionsArg.from} replaces file at ${optionsArg.to}`);
|
||||
}
|
||||
fromArg = plugins.smartpath.transform.toAbsolute(fromArg, paths.cwd) as string;
|
||||
toArg = plugins.smartpath.transform.toAbsolute(toArg, paths.cwd) as string;
|
||||
const fileString = plugins.smartfile.fs.toStringSync(fromArg);
|
||||
const minifiedHtml = plugins.htmlMinifier.minify(fileString, {
|
||||
minifyCSS: true,
|
||||
minifyJS: true,
|
||||
sortAttributes: true,
|
||||
sortClassName: true,
|
||||
removeAttributeQuotes: true,
|
||||
collapseWhitespace: true,
|
||||
collapseInlineTagWhitespace: true,
|
||||
removeComments: true,
|
||||
});
|
||||
await plugins.smartfile.memory.toFs(minifiedHtml, toArg);
|
||||
console.log(`html minification succeeded!`);
|
||||
optionsArg.from = plugins.smartpath.transform.toAbsolute(optionsArg.from, paths.cwd) as string;
|
||||
optionsArg.to = plugins.smartpath.transform.toAbsolute(optionsArg.to, paths.cwd) as string;
|
||||
let fileString = plugins.smartfile.fs.toStringSync(optionsArg.from);
|
||||
if (optionsArg.minify) {
|
||||
fileString = plugins.htmlMinifier.minify(fileString, {
|
||||
minifyCSS: true,
|
||||
minifyJS: true,
|
||||
sortAttributes: true,
|
||||
sortClassName: true,
|
||||
removeAttributeQuotes: true,
|
||||
collapseWhitespace: true,
|
||||
collapseInlineTagWhitespace: true,
|
||||
removeComments: true,
|
||||
});
|
||||
}
|
||||
await plugins.smartfile.memory.toFs(fileString, optionsArg.to);
|
||||
console.log(`html processing succeeded!`);
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,6 @@ export const runCli = async () => {
|
||||
|
||||
tsBundleCli.addCommand('element').subscribe(async (argvArg) => {
|
||||
const tsbundle = new TsBundle();
|
||||
const htmlHandler = new HtmlHandler();
|
||||
// const htmlHandler = new HtmlHandler();
|
||||
await tsbundle.build(
|
||||
process.cwd(),
|
||||
'./ts_web/index.ts',
|
||||
@ -43,7 +41,14 @@ export const runCli = async () => {
|
||||
'./dist_serve/bundle.js',
|
||||
argvArg
|
||||
);
|
||||
await htmlHandler.minifyHtml('./html/index.html', './dist_serve/index.html')
|
||||
const htmlFiles = await plugins.smartfile.fs.listFiles('./html', /\.html/);
|
||||
for (const htmlFile of htmlFiles) {
|
||||
await htmlHandler.processHtml({
|
||||
from: `./html/${htmlFile}`,
|
||||
to: `./dist_serve/${htmlFile}`,
|
||||
minify: true,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
tsBundleCli.startParse();
|
||||
|
Loading…
Reference in New Issue
Block a user