Compare commits
26 Commits
Author | SHA1 | Date | |
---|---|---|---|
acc7936a6a | |||
9785399565 | |||
d1bb93e9e1 | |||
5c00555ea8 | |||
7fd0ff65e5 | |||
0cca5cafdf | |||
f5340e7109 | |||
71c917b32f | |||
ac3ef390e8 | |||
7ca9c52cc7 | |||
0c702029f2 | |||
dddd3ead1c | |||
bad5690d99 | |||
a8fb7aac7f | |||
f33f985d3d | |||
ddae40ddb2 | |||
4256578bc6 | |||
1dd604d572 | |||
262fd6e718 | |||
d660550485 | |||
0842c2fdec | |||
20bf5dfc57 | |||
04a77f9eeb | |||
a97af3232a | |||
01953fdfec | |||
2b794967d2 |
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();
|
||||||
|
2094
package-lock.json
generated
2094
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
44
package.json
44
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@gitzone/tsbundle",
|
"name": "@gitzone/tsbundle",
|
||||||
"version": "1.0.43",
|
"version": "1.0.56",
|
||||||
"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",
|
||||||
@ -16,36 +16,36 @@
|
|||||||
"tsbundle": "cli.js"
|
"tsbundle": "cli.js"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.17",
|
"@gitzone/tsbuild": "^2.1.20",
|
||||||
"@gitzone/tsrun": "^1.2.8",
|
"@gitzone/tsrun": "^1.2.8",
|
||||||
"@gitzone/tstest": "^1.0.28",
|
"@gitzone/tstest": "^1.0.28",
|
||||||
"@pushrocks/tapbundle": "^3.0.13",
|
"@pushrocks/tapbundle": "^3.2.0",
|
||||||
"@types/node": "^12.7.11",
|
"tslint": "^6.1.0",
|
||||||
"tslint": "^5.20.0",
|
|
||||||
"tslint-config-prettier": "^1.15.0"
|
"tslint-config-prettier": "^1.15.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/core": "^7.6.2",
|
"@babel/core": "^7.8.7",
|
||||||
"@babel/plugin-proposal-class-properties": "^7.5.5",
|
"@babel/plugin-proposal-class-properties": "^7.8.3",
|
||||||
"@babel/plugin-proposal-decorators": "^7.6.0",
|
"@babel/plugin-proposal-decorators": "^7.8.3",
|
||||||
"@babel/plugin-transform-runtime": "^7.6.2",
|
"@babel/plugin-transform-runtime": "^7.8.3",
|
||||||
"@babel/preset-env": "^7.6.2",
|
"@babel/preset-env": "^7.8.7",
|
||||||
"@babel/runtime": "^7.6.2",
|
"@babel/runtime": "^7.8.7",
|
||||||
"@pushrocks/early": "^3.0.3",
|
"@pushrocks/early": "^3.0.3",
|
||||||
"@pushrocks/smartcli": "^3.0.7",
|
"@pushrocks/smartcli": "^3.0.9",
|
||||||
"@pushrocks/smartfile": "^7.0.6",
|
"@pushrocks/smartfile": "^7.0.9",
|
||||||
"@pushrocks/smartlog": "^2.0.19",
|
"@pushrocks/smartlog": "^2.0.21",
|
||||||
"@pushrocks/smartlog-destination-local": "^8.0.2",
|
"@pushrocks/smartlog-destination-local": "^8.0.2",
|
||||||
|
"@rollup/plugin-commonjs": "^11.0.2",
|
||||||
|
"@rollup/plugin-node-resolve": "^7.1.1",
|
||||||
|
"@rollup/plugin-typescript": "^4.0.0",
|
||||||
"@types/html-minifier": "^3.5.3",
|
"@types/html-minifier": "^3.5.3",
|
||||||
|
"@types/node": "^13.9.1",
|
||||||
"html-minifier": "^4.0.0",
|
"html-minifier": "^4.0.0",
|
||||||
"rollup": "^1.23.1",
|
"rollup": "^2.0.6",
|
||||||
"rollup-plugin-babel": "^4.3.2",
|
"rollup-plugin-babel": "^4.4.0",
|
||||||
"rollup-plugin-commonjs": "^10.1.0",
|
"rollup-plugin-sourcemaps": "^0.5.0",
|
||||||
"rollup-plugin-node-resolve": "^5.2.0",
|
"rollup-plugin-terser": "^5.3.0",
|
||||||
"rollup-plugin-sourcemaps": "^0.4.2",
|
"terser": "^4.6.6"
|
||||||
"rollup-plugin-terser": "^5.1.2",
|
|
||||||
"rollup-plugin-typescript2": "^0.24.3",
|
|
||||||
"terser": "4.3.6"
|
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/*",
|
"ts/*",
|
||||||
|
@ -2,8 +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 () => {
|
||||||
tsbundle;
|
await tsbundle.runCli();
|
||||||
console.log('hi');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
@ -7,9 +7,9 @@ import { logger } from './tsbundle.logging';
|
|||||||
import { runCli } from './tsbundle.cli';
|
import { runCli } from './tsbundle.cli';
|
||||||
early.stop();
|
early.stop();
|
||||||
|
|
||||||
if (process.env.CLI_CALL) {
|
|
||||||
runCli();
|
|
||||||
}
|
|
||||||
|
|
||||||
// lets make this usable programmatically
|
// lets make this usable programmatically
|
||||||
export * from './tsbundle.class.tsbundle';
|
export * from './tsbundle.class.tsbundle';
|
||||||
|
export * from './tsbundle.htmlhandler';
|
||||||
|
export {
|
||||||
|
runCli
|
||||||
|
};
|
||||||
|
@ -5,7 +5,7 @@ export class TsBundle {
|
|||||||
/**
|
/**
|
||||||
* the basic default options for rollup
|
* the basic default options for rollup
|
||||||
*/
|
*/
|
||||||
public getBaseOptions(fromArg: string = `ts_web/index.ts`, toArg: string = 'dist_web/bundle.js') {
|
public getBaseOptions(fromArg: string = `ts_web/index.ts`, toArg: string = 'dist_bundle/bundle.js') {
|
||||||
logger.log('info', `from: ${fromArg}`);
|
logger.log('info', `from: ${fromArg}`);
|
||||||
logger.log('info', `to: ${toArg}`);
|
logger.log('info', `to: ${toArg}`);
|
||||||
|
|
||||||
@ -25,19 +25,14 @@ export class TsBundle {
|
|||||||
plugins: [
|
plugins: [
|
||||||
// Compile TypeScript files
|
// Compile TypeScript files
|
||||||
plugins.rollupTypescript({
|
plugins.rollupTypescript({
|
||||||
useTsconfigDeclarationDir: true,
|
declaration: false,
|
||||||
tsconfigOverride: {
|
emitDecoratorMetadata: true,
|
||||||
compilerOptions: {
|
experimentalDecorators: true,
|
||||||
declaration: true,
|
inlineSourceMap: true,
|
||||||
emitDecoratorMetadata: true,
|
noEmitOnError: true,
|
||||||
experimentalDecorators: true,
|
lib: ['esnext', 'dom'],
|
||||||
inlineSourceMap: true,
|
noImplicitAny: false,
|
||||||
noEmitOnError: true,
|
target: 'es2018'
|
||||||
lib: ['es2017', 'dom'],
|
|
||||||
target: 'es2017',
|
|
||||||
noImplicitAny: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
// Allow node_modules resolution, so you can use 'external' to control
|
// Allow node_modules resolution, so you can use 'external' to control
|
||||||
// which external modules to include in the bundle
|
// which external modules to include in the bundle
|
||||||
@ -88,9 +83,7 @@ export class TsBundle {
|
|||||||
const productionOptions = this.getBaseOptions(fromArg, toArg);
|
const productionOptions = this.getBaseOptions(fromArg, toArg);
|
||||||
productionOptions.plugins.push(plugins.rollupTerser({
|
productionOptions.plugins.push(plugins.rollupTerser({
|
||||||
compress: true,
|
compress: true,
|
||||||
mangle: false,
|
mangle: true,
|
||||||
toplevel: false,
|
|
||||||
keep_classnames: true,
|
|
||||||
sourcemap: true
|
sourcemap: true
|
||||||
}));
|
}));
|
||||||
return productionOptions;
|
return productionOptions;
|
||||||
@ -108,8 +101,8 @@ export class TsBundle {
|
|||||||
logger.log('info', `bundling for TEST!`);
|
logger.log('info', `bundling for TEST!`);
|
||||||
const buildOptions = this.getOptionsTest(fromArg, toArg);
|
const buildOptions = this.getOptionsTest(fromArg, toArg);
|
||||||
const bundle = await plugins.rollup.rollup(buildOptions);
|
const bundle = await plugins.rollup.rollup(buildOptions);
|
||||||
bundle.generate(buildOptions.output);
|
bundle.generate(buildOptions.output as plugins.rollup.OutputOptions);
|
||||||
await bundle.write(buildOptions.output);
|
await bundle.write(buildOptions.output as plugins.rollup.OutputOptions);
|
||||||
logger.log('ok', `Successfully bundled files!`);
|
logger.log('ok', `Successfully bundled files!`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,8 +114,8 @@ export class TsBundle {
|
|||||||
logger.log('info', `bundling for PRODUCTION!`);
|
logger.log('info', `bundling for PRODUCTION!`);
|
||||||
const buildOptions = this.getOptionsProduction(fromArg, toArg);
|
const buildOptions = this.getOptionsProduction(fromArg, toArg);
|
||||||
const bundle = await plugins.rollup.rollup(buildOptions);
|
const bundle = await plugins.rollup.rollup(buildOptions);
|
||||||
bundle.generate(buildOptions.output);
|
bundle.generate(buildOptions.output as plugins.rollup.OutputOptions);
|
||||||
await bundle.write(buildOptions.output);
|
await bundle.write(buildOptions.output as plugins.rollup.OutputOptions);
|
||||||
logger.log('ok', `Successfully bundled files!`);
|
logger.log('ok', `Successfully bundled files!`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,15 +7,47 @@ 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();
|
// const htmlHandler = new HtmlHandler();
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case argvArg.production || process.env.CI:
|
case argvArg.production || process.env.CI:
|
||||||
await tsbundle.buildProduction(argvArg.from, argvArg.to);
|
await tsbundle.buildProduction(argvArg.from, argvArg.to);
|
||||||
await htmlHandler.minifyHtml();
|
// await htmlHandler.minifyHtml();
|
||||||
break;
|
break;
|
||||||
case argvArg.test:
|
case argvArg.test:
|
||||||
default:
|
default:
|
||||||
await tsbundle.buildTest(argvArg.from, argvArg.to);
|
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_bundle/bundle.js');
|
||||||
|
// await htmlHandler.minifyHtml();
|
||||||
|
break;
|
||||||
|
case argvArg.test:
|
||||||
|
default:
|
||||||
|
await tsbundle.buildTest('./ts_web/index.ts', './dist_bundle/bundle.js');
|
||||||
|
// await htmlHandler.copyHtml();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
tsBundleCli.addCommand('website').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_serve/bundle.js');
|
||||||
|
await htmlHandler.minifyHtml();
|
||||||
|
break;
|
||||||
|
case argvArg.test:
|
||||||
|
default:
|
||||||
|
await tsbundle.buildTest('./ts_web/index.ts', './dist_serve/bundle.js');
|
||||||
await htmlHandler.copyHtml();
|
await htmlHandler.copyHtml();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3,22 +3,22 @@ import * as paths from './tsbundle.paths';
|
|||||||
|
|
||||||
export class HtmlHandler {
|
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.distServeDir, 'index.html');
|
||||||
|
|
||||||
public async checkIfExists() {
|
public async checkIfExists() {
|
||||||
return plugins.smartfile.fs.fileExists(this.sourceFilePath);
|
return plugins.smartfile.fs.fileExists(this.sourceFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// copies the html
|
// copies the html
|
||||||
public async copyHtml() {
|
public async copyHtml(targetPathArg = this.targetFilePath) {
|
||||||
if (!(await this.checkIfExists())) {
|
if (!(await this.checkIfExists())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await plugins.smartfile.fs.copy(this.sourceFilePath, this.targetFilePath);
|
await plugins.smartfile.fs.copy(this.sourceFilePath, targetPathArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// copies and minifies the html
|
// copies and minifies the html
|
||||||
public async minifyHtml() {
|
public async minifyHtml(targetPathArg = this.targetFilePath) {
|
||||||
if (!(await this.checkIfExists())) {
|
if (!(await this.checkIfExists())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -33,6 +33,6 @@ export class HtmlHandler {
|
|||||||
collapseInlineTagWhitespace: true,
|
collapseInlineTagWhitespace: true,
|
||||||
removeComments: true
|
removeComments: true
|
||||||
});
|
});
|
||||||
plugins.smartfile.memory.toFsSync(minifiedHtml, this.targetFilePath);
|
plugins.smartfile.memory.toFsSync(minifiedHtml, targetPathArg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,4 +3,5 @@ import * as plugins from './tsbundle.plugins';
|
|||||||
export const cwd = process.cwd();
|
export const cwd = process.cwd();
|
||||||
export const packageDir = plugins.path.join(__dirname, '../');
|
export const packageDir = plugins.path.join(__dirname, '../');
|
||||||
export const htmlDir = plugins.path.join(cwd, './html');
|
export const htmlDir = plugins.path.join(cwd, './html');
|
||||||
export const distWebDir = plugins.path.join(cwd, './dist_web');
|
export const distServeDir = plugins.path.join(cwd, './dist_serve');
|
||||||
|
export const assetsDir = plugins.path.join(packageDir, 'assets');
|
||||||
|
@ -14,11 +14,11 @@ export { smartcli, smartfile, smartlog, smartlogDestinationLocal };
|
|||||||
// third party scope
|
// 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 { terser as rollupTerser } from 'rollup-plugin-terser';
|
||||||
import rollupTypescript from 'rollup-plugin-typescript2';
|
import rollupTypescript from '@rollup/plugin-typescript';
|
||||||
|
|
||||||
import * as htmlMinifier from 'html-minifier';
|
import * as htmlMinifier from 'html-minifier';
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user