Compare commits

...

12 Commits

Author SHA1 Message Date
8f17a3c92a 1.0.29 2019-07-17 12:00:04 +02:00
65221425ca fix(core): update 2019-07-17 12:00:04 +02:00
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
7c5ed463fe 1.0.25 2019-06-16 17:47:34 +02:00
b1a5426405 fix(core): update 2019-06-16 17:47:34 +02:00
6a33742e27 1.0.24 2019-06-16 17:03:47 +02:00
3d201016fd fix(core): update 2019-06-16 17:03:47 +02:00
8 changed files with 1169 additions and 2090 deletions

2904
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "@gitzone/tsbundle",
"version": "1.0.23",
"version": "1.0.29",
"private": false,
"description": "a bundler using rollup for painless bundling of web projects",
"main": "dist/index.js",
@ -20,7 +20,7 @@
"@gitzone/tsrun": "^1.2.6",
"@gitzone/tstest": "^1.0.15",
"@pushrocks/tapbundle": "^3.0.7",
"@types/node": "^11.13.8",
"@types/node": "^12.6.6",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0"
},
@ -33,15 +33,18 @@
"@babel/runtime": "^7.4.4",
"@pushrocks/early": "^3.0.3",
"@pushrocks/smartcli": "^3.0.7",
"@pushrocks/smartfile": "^7.0.2",
"@pushrocks/smartlog": "^2.0.19",
"@pushrocks/smartlog-destination-local": "^7.0.5",
"@pushrocks/smartlog-destination-local": "^8.0.2",
"@types/html-minifier": "^3.5.3",
"html-minifier": "^4.0.0",
"rollup": "^1.10.1",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-commonjs": "^9.3.4",
"rollup-plugin-node-resolve": "^4.2.3",
"rollup-plugin-commonjs": "^10.0.1",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-terser": "^5.0.0",
"rollup-plugin-typescript2": "^0.21.0"
"rollup-plugin-typescript2": "^0.22.0"
},
"files": [
"ts/*",

81
test/html/index.html Normal file
View File

@ -0,0 +1,81 @@
<!-- gitzone default -->
<!-- made by Lossless GmbH -->
<!-- checkout https://maintainedby.lossless.com for awesome OpenSource projects -->
<html lang="en">
<head>
<!--Lets set some basic meta tags-->
<meta
name="viewport"
content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height"
/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--Lets make sure we recognize this as an PWA-->
<link rel="manifest" href="/manifest.json" />
<!--Lets make sure we support older browsers-->
<script src=" https://unpkg.com/@webcomponents/webcomponentsjs@^2/webcomponents-bundle.js"></script>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
<!--Lets avoid a rescaling flicker due to default body margins-->
<style>
body {
margin: 0px;
}
</style>
</head>
<body>
<noscript>
<style>
@import url('https://fonts.googleapis.com/css?family=Roboto:300,400');
body {
background: #303f9f;
font-family: 'Roboto', sans-serif;
color: #ffffff;
}
a {
color: #ffffff;
text-decoration: none;
}
.container {
width: 600px;
margin: auto;
margin-top: 100px;
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.3);
overflow: hidden;
border-radius: 3px;
background: #4357d9;
}
.header {
padding: 20px;
text-align: center;
font-size: 25px;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.content {
padding: 20px;
}
.footer {
padding: 10px;
text-align: center;
}
</style>
<div class="container">
<div class="header">
We need JavaScript to run properly!
</div>
<div class="content">
This site is being built using lit-element (made by Google). This technology works with
JavaScript. Subsequently this website does not work as intended by Lossless GmbH without
JavaScript.
</div>
</div>
<div class="footer">
<a href="https://lossless.gmbh">Legal Info</a> |
<a href="https://lossless.gmbh/privacy">Privacy Policy</a>
</div>
</noscript>
</body>
<script defer src="./bundle.js"></script>
</html>

View File

@ -16,10 +16,10 @@ export class TsBundle {
*/
public async buildTest() {
// create a bundle
logger.log('info', `starting bundling for TEST now!`);
logger.log('info', `bundling for TEST!`);
const bundle = await plugins.rollup.rollup(this.optionsTest);
bundle.generate(this.optionsTest.output);
bundle.write(this.optionsTest.output);
await bundle.write(this.optionsTest.output);
logger.log('ok', `Successfully bundled files!`);
}
@ -28,10 +28,10 @@ export class TsBundle {
*/
public async buildProduction() {
// create a bundle
logger.log('info', `starting for PRODUCTION now!`);
logger.log('info', `bundling for PRODUCTION!`);
const bundle = await plugins.rollup.rollup(this.optionsProduction);
bundle.generate(this.optionsProduction.output);
bundle.write(this.optionsProduction.output);
await bundle.write(this.optionsProduction.output);
logger.log('ok', `Successfully bundled files!`);
}

View File

@ -1,20 +1,22 @@
import * as plugins from './tsbundle.plugins';
import { TsBundle } from './tsbundle.class.tsbundle';
import { HtmlHandler } from './tsbundle.htmlhandler';
import { logger } from './tsbundle.logging';
export const runCli = async () => {
const tsBundleCli = new plugins.smartcli.Smartcli();
tsBundleCli.standardTask().subscribe(async argvArg => {
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:
await tsbundle.buildTest();
break;
default:
logger.log('error', `Can not determine build target environement. Please specify via --production or --test`)
await tsbundle.buildTest();
await htmlHandler.copyHtml();
return;
}
});

View File

@ -0,0 +1,42 @@
import * as plugins from './tsbundle.plugins';
import * as paths from './tsbundle.paths';
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
);
}
// 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,
minifyJS: true,
sortAttributes: true,
sortClassName: true,
removeAttributeQuotes: true,
collapseWhitespace: true,
collapseInlineTagWhitespace: true,
removeComments: true
});
plugins.smartfile.memory.toFsSync(minifiedHtml, this.targetFilePath);
}
}

6
ts/tsbundle.paths.ts Normal file
View File

@ -0,0 +1,6 @@
import * as plugins from './tsbundle.plugins';
export const cwd = process.cwd();
export const packageDir = plugins.path.join(__dirname, '../');
export const htmlDir = plugins.path.join(cwd, './html');
export const distWebDir = plugins.path.join(cwd, './dist_web');

View File

@ -1,9 +1,17 @@
// node native
import * as path from 'path';
export {
path
};
// pushrocks scope
import * as smartcli from '@pushrocks/smartcli';
import * as smartfile from '@pushrocks/smartfile';
import * as smartlog from '@pushrocks/smartlog';
import * as smartlogDestinationLocal from '@pushrocks/smartlog-destination-local';
export { smartcli, smartlog, smartlogDestinationLocal };
export { smartcli, smartfile, smartlog, smartlogDestinationLocal };
// third party scope
import * as rollup from 'rollup';
@ -14,6 +22,8 @@ import rollupSourceMaps from 'rollup-plugin-sourcemaps';
import { terser as rollupTerser } from 'rollup-plugin-terser';
import rollupTypescript from 'rollup-plugin-typescript2';
import * as htmlMinifier from 'html-minifier';
export {
rollup,
rollupBabel,
@ -21,5 +31,6 @@ export {
rollupResolve,
rollupSourceMaps,
rollupTerser,
rollupTypescript
rollupTypescript,
htmlMinifier
};