Compare commits

..

6 Commits

Author SHA1 Message Date
0bc8048ac5 1.0.28 2019-07-17 11:54:50 +02:00
65754d34bc fix(core): update 2019-07-17 11:54:49 +02:00
c4a276ebf3 1.0.27 2019-06-17 07:06:57 +02:00
3db075b795 fix(core): update 2019-06-17 07:06:56 +02:00
f90f391e87 1.0.26 2019-06-16 17:52:20 +02:00
31d886a48a fix(core): update 2019-06-16 17:52:20 +02:00
5 changed files with 21 additions and 9 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@gitzone/tsbundle", "name": "@gitzone/tsbundle",
"version": "1.0.25", "version": "1.0.28",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "@gitzone/tsbundle", "name": "@gitzone/tsbundle",
"version": "1.0.25", "version": "1.0.28",
"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/index.js", "main": "dist/index.js",

View File

@ -19,7 +19,7 @@ export class TsBundle {
logger.log('info', `bundling for TEST!`); logger.log('info', `bundling for TEST!`);
const bundle = await plugins.rollup.rollup(this.optionsTest); const bundle = await plugins.rollup.rollup(this.optionsTest);
bundle.generate(this.optionsTest.output); bundle.generate(this.optionsTest.output);
bundle.write(this.optionsTest.output); await bundle.write(this.optionsTest.output);
logger.log('ok', `Successfully bundled files!`); logger.log('ok', `Successfully bundled files!`);
} }
@ -31,7 +31,7 @@ export class TsBundle {
logger.log('info', `bundling for PRODUCTION!`); logger.log('info', `bundling for PRODUCTION!`);
const bundle = await plugins.rollup.rollup(this.optionsProduction); const bundle = await plugins.rollup.rollup(this.optionsProduction);
bundle.generate(this.optionsProduction.output); bundle.generate(this.optionsProduction.output);
bundle.write(this.optionsProduction.output); await bundle.write(this.optionsProduction.output);
logger.log('ok', `Successfully bundled files!`); logger.log('ok', `Successfully bundled files!`);
} }

View File

@ -9,16 +9,14 @@ export const runCli = async () => {
const tsbundle = new TsBundle(); const tsbundle = new TsBundle();
const htmlHandler = new HtmlHandler(); const htmlHandler = new HtmlHandler();
switch (true) { switch (true) {
case argvArg.production: case (argvArg.production) || process.env.CI:
await tsbundle.buildProduction(); await tsbundle.buildProduction();
await htmlHandler.minifyHtml(); await htmlHandler.minifyHtml();
break; break;
case argvArg.test: case argvArg.test:
default:
await tsbundle.buildTest(); await tsbundle.buildTest();
await htmlHandler.copyHtml(); await htmlHandler.copyHtml();
break;
default:
logger.log('error', `Can not determine build target environement. Please specify via --production or --test`)
return; return;
} }
}); });

View File

@ -5,8 +5,15 @@ export class HtmlHandler {
public sourceFilePath: string = plugins.path.join(paths.htmlDir, 'index.html'); public sourceFilePath: string = plugins.path.join(paths.htmlDir, 'index.html');
public targetFilePath: string = plugins.path.join(paths.distWebDir, '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 // copies the html
public async copyHtml() { public async copyHtml() {
if (!(await this.checkIfExists)) {
return;
}
await plugins.smartfile.fs.copy( await plugins.smartfile.fs.copy(
this.sourceFilePath, this.sourceFilePath,
this.targetFilePath this.targetFilePath
@ -15,13 +22,20 @@ export class HtmlHandler {
// copies and minifies the html // copies and minifies the html
public async minifyHtml() { public async minifyHtml() {
if (!(await this.checkIfExists)) {
return;
}
const fileString = plugins.smartfile.fs.toStringSync(this.sourceFilePath); const fileString = plugins.smartfile.fs.toStringSync(this.sourceFilePath);
const minifiedHtml = plugins.htmlMinifier.minify(fileString, { const minifiedHtml = plugins.htmlMinifier.minify(fileString, {
minifyCSS: true, minifyCSS: true,
minifyJS: true, minifyJS: true,
sortAttributes: true, sortAttributes: true,
sortClassName: true, sortClassName: true,
removeAttributeQuotes: true removeAttributeQuotes: true,
collapseWhitespace: true,
collapseInlineTagWhitespace: true,
removeComments: true
}); });
plugins.smartfile.memory.toFsSync(minifiedHtml, this.targetFilePath); plugins.smartfile.memory.toFsSync(minifiedHtml, this.targetFilePath);
} }