Compare commits

..

4 Commits

Author SHA1 Message Date
0a211e804e 1.0.37 2019-07-19 12:09:00 +02:00
41a886cfcf fix(core): update 2019-07-19 12:09:00 +02:00
62ad70ac6c 1.0.36 2019-07-19 10:52:28 +02:00
455e33488d fix(core): update 2019-07-19 10:52:27 +02:00
5 changed files with 23 additions and 13 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@gitzone/tsbundle", "name": "@gitzone/tsbundle",
"version": "1.0.35", "version": "1.0.37",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "@gitzone/tsbundle", "name": "@gitzone/tsbundle",
"version": "1.0.35", "version": "1.0.37",
"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",

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: {
@ -78,16 +81,18 @@ export class TsBundle {
} }
public getOptionsTest(fromArg: string, toArg: string): plugins.rollup.RollupOptions { public getOptionsTest(fromArg: string, toArg: string): plugins.rollup.RollupOptions {
return this.getBaseOptions(); return this.getBaseOptions(fromArg, toArg);
} }
public getOptionsProduction(fromArg: string, toArg: string): plugins.rollup.RollupOptions { public getOptionsProduction(fromArg: string, toArg: string): plugins.rollup.RollupOptions {
const productionOptions = this.getBaseOptions(); const productionOptions = this.getBaseOptions(fromArg, toArg);
productionOptions.plugins.push(plugins.rollupTerser()); productionOptions.plugins.push(plugins.rollupTerser());
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;
} }