Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
8f17a3c92a | |||
65221425ca | |||
0bc8048ac5 | |||
65754d34bc | |||
c4a276ebf3 | |||
3db075b795 | |||
f90f391e87 | |||
31d886a48a | |||
7c5ed463fe | |||
b1a5426405 |
3082
package-lock.json
generated
3082
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
15
package.json
15
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@gitzone/tsbundle",
|
"name": "@gitzone/tsbundle",
|
||||||
"version": "1.0.24",
|
"version": "1.0.29",
|
||||||
"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",
|
||||||
@ -20,7 +20,7 @@
|
|||||||
"@gitzone/tsrun": "^1.2.6",
|
"@gitzone/tsrun": "^1.2.6",
|
||||||
"@gitzone/tstest": "^1.0.15",
|
"@gitzone/tstest": "^1.0.15",
|
||||||
"@pushrocks/tapbundle": "^3.0.7",
|
"@pushrocks/tapbundle": "^3.0.7",
|
||||||
"@types/node": "^11.13.8",
|
"@types/node": "^12.6.6",
|
||||||
"tslint": "^5.11.0",
|
"tslint": "^5.11.0",
|
||||||
"tslint-config-prettier": "^1.15.0"
|
"tslint-config-prettier": "^1.15.0"
|
||||||
},
|
},
|
||||||
@ -33,15 +33,18 @@
|
|||||||
"@babel/runtime": "^7.4.4",
|
"@babel/runtime": "^7.4.4",
|
||||||
"@pushrocks/early": "^3.0.3",
|
"@pushrocks/early": "^3.0.3",
|
||||||
"@pushrocks/smartcli": "^3.0.7",
|
"@pushrocks/smartcli": "^3.0.7",
|
||||||
|
"@pushrocks/smartfile": "^7.0.2",
|
||||||
"@pushrocks/smartlog": "^2.0.19",
|
"@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": "^1.10.1",
|
||||||
"rollup-plugin-babel": "^4.3.2",
|
"rollup-plugin-babel": "^4.3.2",
|
||||||
"rollup-plugin-commonjs": "^9.3.4",
|
"rollup-plugin-commonjs": "^10.0.1",
|
||||||
"rollup-plugin-node-resolve": "^4.2.3",
|
"rollup-plugin-node-resolve": "^5.2.0",
|
||||||
"rollup-plugin-sourcemaps": "^0.4.2",
|
"rollup-plugin-sourcemaps": "^0.4.2",
|
||||||
"rollup-plugin-terser": "^5.0.0",
|
"rollup-plugin-terser": "^5.0.0",
|
||||||
"rollup-plugin-typescript2": "^0.21.0"
|
"rollup-plugin-typescript2": "^0.22.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/*",
|
"ts/*",
|
||||||
|
81
test/html/index.html
Normal file
81
test/html/index.html
Normal 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>
|
@ -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!`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,20 +1,22 @@
|
|||||||
import * as plugins from './tsbundle.plugins';
|
import * as plugins from './tsbundle.plugins';
|
||||||
import { TsBundle } from './tsbundle.class.tsbundle';
|
import { TsBundle } from './tsbundle.class.tsbundle';
|
||||||
|
import { HtmlHandler } from './tsbundle.htmlhandler';
|
||||||
import { logger } from './tsbundle.logging';
|
import { logger } from './tsbundle.logging';
|
||||||
|
|
||||||
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.standardTask().subscribe(async argvArg => {
|
||||||
const tsbundle = new TsBundle();
|
const tsbundle = new TsBundle();
|
||||||
|
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();
|
||||||
break;
|
break;
|
||||||
case argvArg.test:
|
case argvArg.test:
|
||||||
await tsbundle.buildTest();
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
logger.log('error', `Can not determine build target environement. Please specify via --production or --test`)
|
await tsbundle.buildTest();
|
||||||
|
await htmlHandler.copyHtml();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
42
ts/tsbundle.htmlhandler.ts
Normal file
42
ts/tsbundle.htmlhandler.ts
Normal 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
6
ts/tsbundle.paths.ts
Normal 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');
|
@ -1,9 +1,17 @@
|
|||||||
|
// node native
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
|
export {
|
||||||
|
path
|
||||||
|
};
|
||||||
|
|
||||||
// pushrocks scope
|
// pushrocks scope
|
||||||
import * as smartcli from '@pushrocks/smartcli';
|
import * as smartcli from '@pushrocks/smartcli';
|
||||||
|
import * as smartfile from '@pushrocks/smartfile';
|
||||||
import * as smartlog from '@pushrocks/smartlog';
|
import * as smartlog from '@pushrocks/smartlog';
|
||||||
import * as smartlogDestinationLocal from '@pushrocks/smartlog-destination-local';
|
import * as smartlogDestinationLocal from '@pushrocks/smartlog-destination-local';
|
||||||
|
|
||||||
export { smartcli, smartlog, smartlogDestinationLocal };
|
export { smartcli, smartfile, smartlog, smartlogDestinationLocal };
|
||||||
|
|
||||||
// third party scope
|
// third party scope
|
||||||
import * as rollup from 'rollup';
|
import * as rollup from 'rollup';
|
||||||
@ -14,6 +22,8 @@ import rollupSourceMaps from 'rollup-plugin-sourcemaps';
|
|||||||
import { terser as rollupTerser } from 'rollup-plugin-terser';
|
import { terser as rollupTerser } from 'rollup-plugin-terser';
|
||||||
import rollupTypescript from 'rollup-plugin-typescript2';
|
import rollupTypescript from 'rollup-plugin-typescript2';
|
||||||
|
|
||||||
|
import * as htmlMinifier from 'html-minifier';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
rollup,
|
rollup,
|
||||||
rollupBabel,
|
rollupBabel,
|
||||||
@ -21,5 +31,6 @@ export {
|
|||||||
rollupResolve,
|
rollupResolve,
|
||||||
rollupSourceMaps,
|
rollupSourceMaps,
|
||||||
rollupTerser,
|
rollupTerser,
|
||||||
rollupTypescript
|
rollupTypescript,
|
||||||
|
htmlMinifier
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user