Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
0bc8048ac5 | |||
65754d34bc | |||
c4a276ebf3 | |||
3db075b795 |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@gitzone/tsbundle",
|
||||
"version": "1.0.26",
|
||||
"version": "1.0.28",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@gitzone/tsbundle",
|
||||
"version": "1.0.26",
|
||||
"version": "1.0.28",
|
||||
"private": false,
|
||||
"description": "a bundler using rollup for painless bundling of web projects",
|
||||
"main": "dist/index.js",
|
||||
|
@ -9,16 +9,14 @@ export const runCli = async () => {
|
||||
const tsbundle = new TsBundle();
|
||||
const htmlHandler = new HtmlHandler();
|
||||
switch (true) {
|
||||
case argvArg.production:
|
||||
case (argvArg.production) || process.env.CI:
|
||||
await tsbundle.buildProduction();
|
||||
await htmlHandler.minifyHtml();
|
||||
break;
|
||||
case argvArg.test:
|
||||
default:
|
||||
await tsbundle.buildTest();
|
||||
await htmlHandler.copyHtml();
|
||||
break;
|
||||
default:
|
||||
logger.log('error', `Can not determine build target environement. Please specify via --production or --test`)
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
@ -5,8 +5,15 @@ export class HtmlHandler {
|
||||
public sourceFilePath: string = plugins.path.join(paths.htmlDir, 'index.html');
|
||||
public targetFilePath: string = plugins.path.join(paths.distWebDir, 'index.html');
|
||||
|
||||
public async checkIfExists () {
|
||||
return plugins.smartfile.fs.fileExists(this.sourceFilePath);
|
||||
}
|
||||
|
||||
// copies the html
|
||||
public async copyHtml() {
|
||||
if (!(await this.checkIfExists)) {
|
||||
return;
|
||||
}
|
||||
await plugins.smartfile.fs.copy(
|
||||
this.sourceFilePath,
|
||||
this.targetFilePath
|
||||
@ -15,6 +22,9 @@ export class HtmlHandler {
|
||||
|
||||
// copies and minifies the html
|
||||
public async minifyHtml() {
|
||||
if (!(await this.checkIfExists)) {
|
||||
return;
|
||||
}
|
||||
const fileString = plugins.smartfile.fs.toStringSync(this.sourceFilePath);
|
||||
const minifiedHtml = plugins.htmlMinifier.minify(fileString, {
|
||||
minifyCSS: true,
|
||||
|
Reference in New Issue
Block a user