fix(core): update

This commit is contained in:
Philipp Kunz 2019-07-19 10:52:27 +02:00
parent 1af1908e1d
commit 455e33488d
3 changed files with 19 additions and 9 deletions

View File

@ -10,3 +10,6 @@ early.stop();
if (process.env.CLI_CALL) { if (process.env.CLI_CALL) {
runCli(); runCli();
} }
// lets make this usable programmatically
export * from './tsbundle.class.tsbundle';

View File

@ -6,6 +6,9 @@ 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_web/bundle.js') {
logger.log('info', `from: ${fromArg}`);
logger.log('info', `to: ${toArg}`);
const baseOptions: plugins.rollup.RollupOptions = { const baseOptions: plugins.rollup.RollupOptions = {
input: fromArg, input: fromArg,
output: { output: {
@ -87,7 +90,9 @@ export class TsBundle {
return productionOptions; return productionOptions;
} }
constructor() {} constructor() {
// Nothing here
}
/** /**
* creates a bundle for the test enviroment * creates a bundle for the test enviroment
@ -95,9 +100,10 @@ export class TsBundle {
public async buildTest(fromArg: string, toArg: string) { public async buildTest(fromArg: string, toArg: string) {
// create a bundle // create a bundle
logger.log('info', `bundling for TEST!`); logger.log('info', `bundling for TEST!`);
const bundle = await plugins.rollup.rollup(this.getOptionsTest(fromArg, toArg)); const buildOptions = this.getOptionsTest(fromArg, toArg);
bundle.generate(this.getOptionsTest(fromArg, toArg).output); const bundle = await plugins.rollup.rollup(buildOptions);
await bundle.write(this.getOptionsTest(fromArg, toArg).output); bundle.generate(buildOptions.output);
await bundle.write(buildOptions.output);
logger.log('ok', `Successfully bundled files!`); logger.log('ok', `Successfully bundled files!`);
} }
@ -107,9 +113,10 @@ export class TsBundle {
public async buildProduction(fromArg: string, toArg: string) { public async buildProduction(fromArg: string, toArg: string) {
// create a bundle // create a bundle
logger.log('info', `bundling for PRODUCTION!`); logger.log('info', `bundling for PRODUCTION!`);
const bundle = await plugins.rollup.rollup(this.getOptionsProduction(fromArg, toArg)); const buildOptions = this.getOptionsProduction(fromArg, toArg);
bundle.generate(this.getOptionsProduction(fromArg, toArg).output); const bundle = await plugins.rollup.rollup(buildOptions);
await bundle.write(this.getOptionsProduction(fromArg, toArg).output); bundle.generate(buildOptions.output);
await bundle.write(buildOptions.output);
logger.log('ok', `Successfully bundled files!`); logger.log('ok', `Successfully bundled files!`);
} }
} }

View File

@ -10,12 +10,12 @@ export const runCli = async () => {
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(null, null); 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(null, null); await tsbundle.buildTest(argvArg.from, argvArg.to);
await htmlHandler.copyHtml(); await htmlHandler.copyHtml();
return; return;
} }