Compare commits
66 Commits
Author | SHA1 | Date | |
---|---|---|---|
ac3ef390e8 | |||
7ca9c52cc7 | |||
0c702029f2 | |||
dddd3ead1c | |||
bad5690d99 | |||
a8fb7aac7f | |||
f33f985d3d | |||
ddae40ddb2 | |||
4256578bc6 | |||
1dd604d572 | |||
262fd6e718 | |||
d660550485 | |||
0842c2fdec | |||
20bf5dfc57 | |||
04a77f9eeb | |||
a97af3232a | |||
01953fdfec | |||
2b794967d2 | |||
eacda66c43 | |||
5f048712e1 | |||
6d6c851274 | |||
afc3141fb2 | |||
317487ffaa | |||
ac8d603060 | |||
c46621517b | |||
4b283ad6a3 | |||
6f3aab9232 | |||
de60087146 | |||
b1730c0cc6 | |||
b39c928b1e | |||
0a211e804e | |||
41a886cfcf | |||
62ad70ac6c | |||
455e33488d | |||
1af1908e1d | |||
31967ab846 | |||
93fda3944a | |||
d0ce17299a | |||
1b0fa5b465 | |||
7a6f9d9569 | |||
ebcf89520a | |||
ca6ef86c8c | |||
a98471e914 | |||
7755286aab | |||
8f17a3c92a | |||
65221425ca | |||
0bc8048ac5 | |||
65754d34bc | |||
c4a276ebf3 | |||
3db075b795 | |||
f90f391e87 | |||
31d886a48a | |||
7c5ed463fe | |||
b1a5426405 | |||
6a33742e27 | |||
3d201016fd | |||
57405ac944 | |||
508bb44348 | |||
834934f10e | |||
80dfe00743 | |||
b5f6e8a2ca | |||
ae375e30e3 | |||
a5d1927dcb | |||
69bdb3796d | |||
72af757ea0 | |||
a7d87f7e20 |
8
.gitignore
vendored
8
.gitignore
vendored
@ -8,13 +8,15 @@ pages/
|
|||||||
# installs
|
# installs
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|
||||||
# caches and builds
|
# caches
|
||||||
.yarn/
|
.yarn/
|
||||||
.cache/
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
dist/
|
dist/
|
||||||
dist_web/
|
dist_web/
|
||||||
dist_serve/
|
dist_serve/
|
||||||
dist_ts_web/
|
dist_ts_web/
|
||||||
|
|
||||||
# custom
|
# custom
|
||||||
.rpt2_cache
|
|
@ -1,5 +1,7 @@
|
|||||||
# gitzone standard
|
# gitzone ci_default
|
||||||
image: hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
variables:
|
||||||
|
GIT_STRATEGY: clone
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
@ -38,19 +40,7 @@ snyk:
|
|||||||
# test stage
|
# test stage
|
||||||
# ====================
|
# ====================
|
||||||
|
|
||||||
testLTS:
|
testStable:
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install lts
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
testSTABLE:
|
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
@ -60,12 +50,24 @@ testSTABLE:
|
|||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
|
testBuild:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci node install lts
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command npm run build
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci node install stable
|
- npmci node install lts
|
||||||
- npmci npm publish
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
@ -78,19 +80,11 @@ release:
|
|||||||
# ====================
|
# ====================
|
||||||
codequality:
|
codequality:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
image: docker:stable
|
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
services:
|
|
||||||
- docker:stable-dind
|
|
||||||
script:
|
script:
|
||||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
- npmci command npm install -g tslint typescript
|
||||||
- docker run
|
- npmci npm install
|
||||||
--env SOURCE_CODE="$PWD"
|
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||||
--volume "$PWD":/code
|
|
||||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
|
|
||||||
artifacts:
|
|
||||||
paths: [codeclimate.json]
|
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
- priv
|
- priv
|
||||||
@ -106,13 +100,15 @@ trigger:
|
|||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
image: hosttoday/ht-docker-node:npmci
|
image: hosttoday/ht-docker-dbase:npmci
|
||||||
|
services:
|
||||||
|
- docker:18-dind
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g typedoc typescript
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
- npmci command tsdoc
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
4
.snyk
Normal file
4
.snyk
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
|
||||||
|
version: v1.13.5
|
||||||
|
ignore: {}
|
||||||
|
patch: {}
|
3
cli.js
3
cli.js
@ -1,3 +1,4 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
process.env.CLI_CALL = 'true';
|
process.env.CLI_CALL = 'true';
|
||||||
require('./dist/index');
|
const cliTool = require('./dist/index');
|
||||||
|
cliTool.runCli();
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
process.env.CLI_CALL = 'true';
|
process.env.CLI_CALL = 'true';
|
||||||
require('@gitzone/tsrun');
|
require('@gitzone/tsrun');
|
||||||
require('./ts/index');
|
const cliTool = require('./ts/index');
|
||||||
|
cliTool.runCli();
|
||||||
|
3915
package-lock.json
generated
3915
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
56
package.json
56
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@gitzone/tsbundle",
|
"name": "@gitzone/tsbundle",
|
||||||
"version": "1.0.18",
|
"version": "1.0.52",
|
||||||
"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",
|
||||||
@ -8,7 +8,7 @@
|
|||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "cd test && node ../cli.ts.js",
|
"test": "cd test && node ../cli.ts.js --production",
|
||||||
"build": "(tsbuild)",
|
"build": "(tsbuild)",
|
||||||
"format": "(gitzone format)"
|
"format": "(gitzone format)"
|
||||||
},
|
},
|
||||||
@ -16,26 +16,46 @@
|
|||||||
"tsbundle": "cli.js"
|
"tsbundle": "cli.js"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.11",
|
"@gitzone/tsbuild": "^2.1.17",
|
||||||
"@gitzone/tsrun": "^1.2.6",
|
"@gitzone/tsrun": "^1.2.8",
|
||||||
"@gitzone/tstest": "^1.0.15",
|
"@gitzone/tstest": "^1.0.28",
|
||||||
"@pushrocks/tapbundle": "^3.0.7",
|
"@pushrocks/tapbundle": "^3.2.0",
|
||||||
"@types/node": "^11.13.8",
|
"tslint": "^6.0.0",
|
||||||
"tslint": "^5.11.0",
|
|
||||||
"tslint-config-prettier": "^1.15.0"
|
"tslint-config-prettier": "^1.15.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/core": "^7.4.4",
|
"@types/node": "^13.9.0",
|
||||||
"@babel/plugin-proposal-class-properties": "^7.4.4",
|
"@babel/core": "^7.6.2",
|
||||||
"@babel/plugin-proposal-decorators": "^7.4.4",
|
"@babel/plugin-proposal-class-properties": "^7.5.5",
|
||||||
"@babel/preset-env": "^7.4.4",
|
"@babel/plugin-proposal-decorators": "^7.6.0",
|
||||||
|
"@babel/plugin-transform-runtime": "^7.6.2",
|
||||||
|
"@babel/preset-env": "^7.6.2",
|
||||||
|
"@babel/runtime": "^7.6.2",
|
||||||
"@pushrocks/early": "^3.0.3",
|
"@pushrocks/early": "^3.0.3",
|
||||||
"@pushrocks/smartcli": "^3.0.7",
|
"@pushrocks/smartcli": "^3.0.7",
|
||||||
"rollup": "^1.10.1",
|
"@pushrocks/smartfile": "^7.0.8",
|
||||||
|
"@pushrocks/smartlog": "^2.0.21",
|
||||||
|
"@pushrocks/smartlog-destination-local": "^8.0.2",
|
||||||
|
"@types/html-minifier": "^3.5.3",
|
||||||
|
"html-minifier": "^4.0.0",
|
||||||
|
"rollup": "^1.32.0",
|
||||||
"rollup-plugin-babel": "^4.3.2",
|
"rollup-plugin-babel": "^4.3.2",
|
||||||
"rollup-plugin-commonjs": "^9.3.4",
|
"rollup-plugin-commonjs": "^10.1.0",
|
||||||
"rollup-plugin-node-resolve": "^4.2.3",
|
"rollup-plugin-node-resolve": "^5.2.0",
|
||||||
"rollup-plugin-sourcemaps": "^0.4.2",
|
"rollup-plugin-sourcemaps": "^0.5.0",
|
||||||
"rollup-plugin-typescript2": "^0.21.0"
|
"rollup-plugin-terser": "^5.2.0",
|
||||||
}
|
"rollup-plugin-typescript2": "^0.26.0",
|
||||||
|
"terser": "^4.6.4"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"ts/*",
|
||||||
|
"ts_web/*",
|
||||||
|
"dist/*",
|
||||||
|
"dist_web/*",
|
||||||
|
"dist_ts_web/*",
|
||||||
|
"assets/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,6 @@ tsbundle will bundle modern JavaScript websites in an Google Bot conformant way
|
|||||||
For further information read the linked docs at the top of this readme.
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||||
|
|
||||||
[](https://maintainedby.lossless.com)
|
[](https://maintainedby.lossless.com)
|
||||||
|
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>
|
@ -2,7 +2,7 @@ import { expect, tap } from '@pushrocks/tapbundle';
|
|||||||
import * as tsbundle from '../ts/index';
|
import * as tsbundle from '../ts/index';
|
||||||
|
|
||||||
tap.test('first test', async () => {
|
tap.test('first test', async () => {
|
||||||
console.log(tsbundle.standardExport);
|
await tsbundle.runCli();
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
70
ts/index.ts
70
ts/index.ts
@ -1,61 +1,15 @@
|
|||||||
import * as plugins from './tsbundle.plugins';
|
import * as early from '@pushrocks/early';
|
||||||
|
early.start('tsbundle');
|
||||||
|
// lets import all plugins beforehand
|
||||||
|
import './tsbundle.plugins';
|
||||||
|
|
||||||
const rollupOptions: plugins.rollup.RollupOptions = {
|
import { logger } from './tsbundle.logging';
|
||||||
input: `ts_web/index.ts`,
|
import { runCli } from './tsbundle.cli';
|
||||||
output: {
|
early.stop();
|
||||||
name: 'tsbundle',
|
|
||||||
// file: 'dist_web/bundle.js',
|
|
||||||
file: 'dist_web/bundle.js',
|
|
||||||
format: 'iife',
|
|
||||||
sourcemap: true
|
|
||||||
},
|
|
||||||
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
|
|
||||||
external: [],
|
|
||||||
watch: {
|
|
||||||
include: ['src/**']
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
// Compile TypeScript files
|
|
||||||
plugins.rollupTypescript({
|
|
||||||
useTsconfigDeclarationDir: true,
|
|
||||||
tsconfigOverride: {
|
|
||||||
compilerOptions: {
|
|
||||||
declaration: true,
|
|
||||||
emitDecoratorMetadata: true,
|
|
||||||
experimentalDecorators: true,
|
|
||||||
inlineSourceMap: true,
|
|
||||||
noEmitOnError: true,
|
|
||||||
lib: ['es2017', 'dom'],
|
|
||||||
target: 'es2017',
|
|
||||||
noImplicitAny: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
// Allow node_modules resolution, so you can use 'external' to control
|
|
||||||
// which external modules to include in the bundle
|
|
||||||
// https://github.com/rollup/rollup-plugin-node-resolve#usage
|
|
||||||
plugins.rollupResolve(),
|
|
||||||
plugins.rollupCommonjs({
|
|
||||||
namedExports: {
|
|
||||||
'node_modules/@pushrocks/smartstate/dist/index.js': ['Smartstate']
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
|
|
||||||
// Resolve source maps to the original source
|
// lets make this usable programmatically
|
||||||
plugins.rollupSourceMaps(),
|
export * from './tsbundle.class.tsbundle';
|
||||||
plugins.rollupBabel({
|
export * from './tsbundle.htmlhandler';
|
||||||
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
export {
|
||||||
babelrc: false,
|
runCli
|
||||||
presets: [['@babel/preset-env', { modules: false }]]
|
|
||||||
})
|
|
||||||
]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
async function build() {
|
|
||||||
// create a bundle
|
|
||||||
const bundle = await plugins.rollup.rollup(rollupOptions);
|
|
||||||
bundle.generate(rollupOptions.output);
|
|
||||||
bundle.write(rollupOptions.output);
|
|
||||||
}
|
|
||||||
|
|
||||||
build();
|
|
||||||
|
126
ts/tsbundle.class.tsbundle.ts
Normal file
126
ts/tsbundle.class.tsbundle.ts
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
import * as plugins from './tsbundle.plugins';
|
||||||
|
import { logger } from './tsbundle.logging';
|
||||||
|
|
||||||
|
export class TsBundle {
|
||||||
|
/**
|
||||||
|
* the basic default options for rollup
|
||||||
|
*/
|
||||||
|
public getBaseOptions(fromArg: string = `ts_web/index.ts`, toArg: string = 'dist_web/bundle.js') {
|
||||||
|
logger.log('info', `from: ${fromArg}`);
|
||||||
|
logger.log('info', `to: ${toArg}`);
|
||||||
|
|
||||||
|
const baseOptions: plugins.rollup.RollupOptions = {
|
||||||
|
input: fromArg,
|
||||||
|
output: {
|
||||||
|
name: 'tsbundle',
|
||||||
|
file: toArg,
|
||||||
|
format: 'iife',
|
||||||
|
sourcemap: true
|
||||||
|
},
|
||||||
|
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
|
||||||
|
external: [],
|
||||||
|
watch: {
|
||||||
|
include: ['src/**']
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
// Compile TypeScript files
|
||||||
|
plugins.rollupTypescript({
|
||||||
|
useTsconfigDeclarationDir: true,
|
||||||
|
tsconfigOverride: {
|
||||||
|
compilerOptions: {
|
||||||
|
declaration: true,
|
||||||
|
emitDecoratorMetadata: true,
|
||||||
|
experimentalDecorators: true,
|
||||||
|
inlineSourceMap: true,
|
||||||
|
noEmitOnError: true,
|
||||||
|
lib: ['esnext', 'dom'],
|
||||||
|
target: 'es2018',
|
||||||
|
noImplicitAny: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
// Allow node_modules resolution, so you can use 'external' to control
|
||||||
|
// which external modules to include in the bundle
|
||||||
|
// https://github.com/rollup/rollup-plugin-node-resolve#usage
|
||||||
|
plugins.rollupResolve(),
|
||||||
|
plugins.rollupCommonjs({
|
||||||
|
namedExports: {
|
||||||
|
'node_modules/@pushrocks/smartstate/dist/index.js': ['Smartstate']
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
|
// Resolve source maps to the original source
|
||||||
|
plugins.rollupSourceMaps()
|
||||||
|
/*plugins.rollupBabel({
|
||||||
|
runtimeHelpers: true,
|
||||||
|
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
||||||
|
babelrc: false,
|
||||||
|
presets: [
|
||||||
|
[
|
||||||
|
'@babel/preset-env',
|
||||||
|
{
|
||||||
|
modules: false,
|
||||||
|
targets: {
|
||||||
|
chrome: '41'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
],
|
||||||
|
plugins: [
|
||||||
|
[
|
||||||
|
'@babel/plugin-transform-runtime',
|
||||||
|
{
|
||||||
|
regenerator: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
})*/
|
||||||
|
]
|
||||||
|
};
|
||||||
|
return baseOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getOptionsTest(fromArg: string, toArg: string): plugins.rollup.RollupOptions {
|
||||||
|
return this.getBaseOptions(fromArg, toArg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public getOptionsProduction(fromArg: string, toArg: string): plugins.rollup.RollupOptions {
|
||||||
|
const productionOptions = this.getBaseOptions(fromArg, toArg);
|
||||||
|
productionOptions.plugins.push(plugins.rollupTerser({
|
||||||
|
compress: true,
|
||||||
|
mangle: true,
|
||||||
|
sourcemap: true
|
||||||
|
}));
|
||||||
|
return productionOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
// Nothing here
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* creates a bundle for the test enviroment
|
||||||
|
*/
|
||||||
|
public async buildTest(fromArg: string, toArg: string) {
|
||||||
|
// create a bundle
|
||||||
|
logger.log('info', `bundling for TEST!`);
|
||||||
|
const buildOptions = this.getOptionsTest(fromArg, toArg);
|
||||||
|
const bundle = await plugins.rollup.rollup(buildOptions);
|
||||||
|
bundle.generate(buildOptions.output as plugins.rollup.OutputOptions);
|
||||||
|
await bundle.write(buildOptions.output as plugins.rollup.OutputOptions);
|
||||||
|
logger.log('ok', `Successfully bundled files!`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* creates a bundle for the production environment
|
||||||
|
*/
|
||||||
|
public async buildProduction(fromArg: string, toArg: string) {
|
||||||
|
// create a bundle
|
||||||
|
logger.log('info', `bundling for PRODUCTION!`);
|
||||||
|
const buildOptions = this.getOptionsProduction(fromArg, toArg);
|
||||||
|
const bundle = await plugins.rollup.rollup(buildOptions);
|
||||||
|
bundle.generate(buildOptions.output as plugins.rollup.OutputOptions);
|
||||||
|
await bundle.write(buildOptions.output as plugins.rollup.OutputOptions);
|
||||||
|
logger.log('ok', `Successfully bundled files!`);
|
||||||
|
}
|
||||||
|
}
|
41
ts/tsbundle.cli.ts
Normal file
41
ts/tsbundle.cli.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
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 || process.env.CI:
|
||||||
|
await tsbundle.buildProduction(argvArg.from, argvArg.to);
|
||||||
|
await htmlHandler.minifyHtml();
|
||||||
|
break;
|
||||||
|
case argvArg.test:
|
||||||
|
default:
|
||||||
|
await tsbundle.buildTest(argvArg.from, argvArg.to);
|
||||||
|
await htmlHandler.copyHtml();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
tsBundleCli.addCommand('element').subscribe(async argvArg => {
|
||||||
|
const tsbundle = new TsBundle();
|
||||||
|
// const htmlHandler = new HtmlHandler();
|
||||||
|
switch (true) {
|
||||||
|
case argvArg.production || process.env.CI:
|
||||||
|
await tsbundle.buildProduction('./ts_web/index.ts', './dist_ts_web/bundle.js');
|
||||||
|
// await htmlHandler.minifyHtml();
|
||||||
|
break;
|
||||||
|
case argvArg.test:
|
||||||
|
default:
|
||||||
|
await tsbundle.buildTest('./ts_web/index.ts', './dist_ts_web/bundle.js');
|
||||||
|
// await htmlHandler.copyHtml();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
tsBundleCli.startParse();
|
||||||
|
};
|
38
ts/tsbundle.htmlhandler.ts
Normal file
38
ts/tsbundle.htmlhandler.ts
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
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(targetPathArg = this.targetFilePath) {
|
||||||
|
if (!(await this.checkIfExists())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await plugins.smartfile.fs.copy(this.sourceFilePath, targetPathArg);
|
||||||
|
}
|
||||||
|
|
||||||
|
// copies and minifies the html
|
||||||
|
public async minifyHtml(targetPathArg = this.targetFilePath) {
|
||||||
|
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, targetPathArg);
|
||||||
|
}
|
||||||
|
}
|
15
ts/tsbundle.logging.ts
Normal file
15
ts/tsbundle.logging.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import * as plugins from './tsbundle.plugins';
|
||||||
|
|
||||||
|
export const logger = new plugins.smartlog.Smartlog({
|
||||||
|
logContext: {
|
||||||
|
company: 'Some Company',
|
||||||
|
companyunit: 'Some CompanyUnit',
|
||||||
|
containerName: 'Some Containername',
|
||||||
|
environment: 'local',
|
||||||
|
runtime: 'node',
|
||||||
|
zone: 'gitzone'
|
||||||
|
},
|
||||||
|
minimumLogLevel: 'silly'
|
||||||
|
});
|
||||||
|
|
||||||
|
logger.addLogDestination(new plugins.smartlogDestinationLocal.DestinationLocal());
|
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,15 +1,34 @@
|
|||||||
|
// 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, smartfile, smartlog, smartlogDestinationLocal };
|
||||||
|
|
||||||
|
// third party scope
|
||||||
import * as rollup from 'rollup';
|
import * as rollup from 'rollup';
|
||||||
import rollupBabel from 'rollup-plugin-babel';
|
import rollupBabel from 'rollup-plugin-babel';
|
||||||
import rollupCommonjs from 'rollup-plugin-commonjs';
|
import rollupCommonjs from 'rollup-plugin-commonjs';
|
||||||
import rollupResolve from 'rollup-plugin-node-resolve';
|
import rollupResolve from 'rollup-plugin-node-resolve';
|
||||||
import rollupSourceMaps from 'rollup-plugin-sourcemaps';
|
import rollupSourceMaps from 'rollup-plugin-sourcemaps';
|
||||||
|
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,
|
||||||
rollupCommonjs,
|
rollupCommonjs,
|
||||||
rollupResolve,
|
rollupResolve,
|
||||||
rollupSourceMaps,
|
rollupSourceMaps,
|
||||||
|
rollupTerser,
|
||||||
rollupTypescript,
|
rollupTypescript,
|
||||||
};
|
htmlMinifier
|
||||||
|
};
|
||||||
|
@ -1 +0,0 @@
|
|||||||
import * as plugins from './tsbundle.plugins';
|
|
Reference in New Issue
Block a user