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

View File

@ -10,12 +10,12 @@ export const runCli = async () => {
const htmlHandler = new HtmlHandler();
switch (true) {
case argvArg.production || process.env.CI:
await tsbundle.buildProduction(null, null);
await tsbundle.buildProduction(argvArg.from, argvArg.to);
await htmlHandler.minifyHtml();
break;
case argvArg.test:
default:
await tsbundle.buildTest(null, null);
await tsbundle.buildTest(argvArg.from, argvArg.to);
await htmlHandler.copyHtml();
return;
}