Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
3de5a91885 | |||
f7ca1b2135 | |||
3076e13179 | |||
f3b50d384a | |||
6dcb3f7c2a | |||
daba025307 | |||
00383171ff | |||
2ce9b08911 | |||
d603baf65e | |||
50e4909984 | |||
7208274156 | |||
41ec42d068 |
11
assets/tsconfig.json
Normal file
11
assets/tsconfig.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"target": "ES2020",
|
||||||
|
"module": "ES2020",
|
||||||
|
"moduleResolution": "node12",
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"preserveValueImports": true,
|
||||||
|
"esModuleInterop": true
|
||||||
|
}
|
||||||
|
}
|
17409
package-lock.json
generated
17409
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
26
package.json
26
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@gitzone/tsbundle",
|
"name": "@gitzone/tsbundle",
|
||||||
"version": "2.0.1",
|
"version": "2.0.7",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "a bundler using rollup for painless bundling of web projects",
|
"description": "a bundler using rollup for painless bundling of web projects",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
@ -16,25 +16,25 @@
|
|||||||
"tsbundle": "cli.js"
|
"tsbundle": "cli.js"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.59",
|
"@gitzone/tsbuild": "^2.1.65",
|
||||||
"@gitzone/tsrun": "^1.2.31",
|
"@gitzone/tsrun": "^1.2.37",
|
||||||
"@gitzone/tstest": "^1.0.69",
|
"@gitzone/tstest": "^1.0.72",
|
||||||
"@pushrocks/tapbundle": "^5.0.2"
|
"@pushrocks/tapbundle": "^5.0.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/early": "^3.0.6",
|
"@pushrocks/early": "^4.0.3",
|
||||||
"@pushrocks/smartcli": "^3.0.14",
|
"@pushrocks/smartcli": "^4.0.3",
|
||||||
"@pushrocks/smartfile": "^9.0.6",
|
"@pushrocks/smartfile": "^10.0.4",
|
||||||
"@pushrocks/smartlog": "^2.0.44",
|
"@pushrocks/smartlog": "^3.0.1",
|
||||||
"@pushrocks/smartlog-destination-local": "^8.0.8",
|
"@pushrocks/smartlog-destination-local": "^8.0.8",
|
||||||
"@pushrocks/smartpath": "^5.0.5",
|
"@pushrocks/smartpath": "^5.0.5",
|
||||||
"@pushrocks/smartpromise": "^3.1.7",
|
"@pushrocks/smartpromise": "^3.1.7",
|
||||||
"@pushrocks/smartspawn": "^2.0.9",
|
"@pushrocks/smartspawn": "^3.0.2",
|
||||||
"@types/html-minifier": "^4.0.2",
|
"@types/html-minifier": "^4.0.2",
|
||||||
"@types/node": "^17.0.21",
|
"@types/node": "^18.6.3",
|
||||||
"esbuild": "0.14.27",
|
"esbuild": "^0.14.53",
|
||||||
"html-minifier": "^4.0.0",
|
"html-minifier": "^4.0.0",
|
||||||
"typescript": "4.7.0"
|
"typescript": "^4.7.4"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@gitzone/tsbundle',
|
name: '@gitzone/tsbundle',
|
||||||
version: '2.0.1',
|
version: '2.0.7',
|
||||||
description: 'a bundler using rollup for painless bundling of web projects'
|
description: 'a bundler using rollup for painless bundling of web projects'
|
||||||
}
|
}
|
||||||
|
@ -10,25 +10,27 @@ export class HtmlHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// copies the html
|
// copies the html
|
||||||
public async copyHtml(fromArg: string = this.defaultFromPath, toArg: string = this.defaultToPath) {
|
public async processHtml(optionsArg: {
|
||||||
|
from?: string;
|
||||||
|
to?: string;
|
||||||
|
minify?: boolean;
|
||||||
|
}) {
|
||||||
|
optionsArg = {
|
||||||
|
... {
|
||||||
|
from: this.defaultFromPath,
|
||||||
|
to: this.defaultToPath,
|
||||||
|
minify: false,
|
||||||
|
},
|
||||||
|
...optionsArg
|
||||||
|
}
|
||||||
if (await this.checkIfExists()) {
|
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;
|
optionsArg.from = plugins.smartpath.transform.toAbsolute(optionsArg.from, paths.cwd) as string;
|
||||||
toArg = plugins.smartpath.transform.toAbsolute(toArg, paths.cwd) as string;
|
optionsArg.to = plugins.smartpath.transform.toAbsolute(optionsArg.to, paths.cwd) as string;
|
||||||
await plugins.smartfile.fs.copy(fromArg, toArg);
|
let fileString = plugins.smartfile.fs.toStringSync(optionsArg.from);
|
||||||
console.log(`html copy succeeded!`);
|
if (optionsArg.minify) {
|
||||||
}
|
fileString = plugins.htmlMinifier.minify(fileString, {
|
||||||
|
|
||||||
// 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}`);
|
|
||||||
}
|
|
||||||
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,
|
minifyCSS: true,
|
||||||
minifyJS: true,
|
minifyJS: true,
|
||||||
sortAttributes: true,
|
sortAttributes: true,
|
||||||
@ -38,7 +40,8 @@ export class HtmlHandler {
|
|||||||
collapseInlineTagWhitespace: true,
|
collapseInlineTagWhitespace: true,
|
||||||
removeComments: true,
|
removeComments: true,
|
||||||
});
|
});
|
||||||
await plugins.smartfile.memory.toFs(minifiedHtml, toArg);
|
}
|
||||||
console.log(`html minification succeeded!`);
|
await plugins.smartfile.memory.toFs(fileString, optionsArg.to);
|
||||||
|
console.log(`html processing succeeded!`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,4 +8,4 @@ export const packageDir = plugins.path.join(
|
|||||||
export const htmlDir = plugins.path.join(cwd, './html');
|
export const htmlDir = plugins.path.join(cwd, './html');
|
||||||
export const distServeDir = plugins.path.join(cwd, './dist_serve');
|
export const distServeDir = plugins.path.join(cwd, './dist_serve');
|
||||||
export const assetsDir = plugins.path.join(packageDir, 'assets');
|
export const assetsDir = plugins.path.join(packageDir, 'assets');
|
||||||
export const tsconfigPath = plugins.path.join(packageDir, './tsconfig.json');
|
export const tsconfigPath = plugins.path.join(assetsDir, './tsconfig.json');
|
||||||
|
@ -5,7 +5,7 @@ import { logger } from './tsbundle.logging.js';
|
|||||||
|
|
||||||
export const runCli = async () => {
|
export const runCli = async () => {
|
||||||
const tsBundleCli = new plugins.smartcli.Smartcli();
|
const tsBundleCli = new plugins.smartcli.Smartcli();
|
||||||
tsBundleCli.standardTask().subscribe(async (argvArg) => {
|
tsBundleCli.standardCommand().subscribe(async (argvArg) => {
|
||||||
const tsbundle = new TsBundle();
|
const tsbundle = new TsBundle();
|
||||||
await tsbundle.build(process.cwd(), argvArg.from, argvArg.to, argvArg);
|
await tsbundle.build(process.cwd(), argvArg.from, argvArg.to, argvArg);
|
||||||
return;
|
return;
|
||||||
@ -13,8 +13,6 @@ export const runCli = async () => {
|
|||||||
|
|
||||||
tsBundleCli.addCommand('element').subscribe(async (argvArg) => {
|
tsBundleCli.addCommand('element').subscribe(async (argvArg) => {
|
||||||
const tsbundle = new TsBundle();
|
const tsbundle = new TsBundle();
|
||||||
const htmlHandler = new HtmlHandler();
|
|
||||||
// const htmlHandler = new HtmlHandler();
|
|
||||||
await tsbundle.build(
|
await tsbundle.build(
|
||||||
process.cwd(),
|
process.cwd(),
|
||||||
'./ts_web/index.ts',
|
'./ts_web/index.ts',
|
||||||
@ -43,7 +41,14 @@ export const runCli = async () => {
|
|||||||
'./dist_serve/bundle.js',
|
'./dist_serve/bundle.js',
|
||||||
argvArg
|
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();
|
tsBundleCli.startParse();
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"target": "ES2020",
|
|
||||||
"module": "ES2020",
|
|
||||||
"moduleResolution": "node12",
|
|
||||||
"useDefineForClassFields": false,
|
"useDefineForClassFields": false,
|
||||||
"preserveValueImports": true,
|
"target": "ES2022",
|
||||||
"esModuleInterop": true
|
"module": "ES2022",
|
||||||
|
"moduleResolution": "nodenext"
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user