Compare commits

...

3 Commits

Author SHA1 Message Date
1af1908e1d 1.0.35 2019-07-18 18:15:25 +02:00
31967ab846 fix(core): update 2019-07-18 18:15:24 +02:00
93fda3944a 1.0.34 2019-07-17 13:50:24 +02:00
4 changed files with 47 additions and 43 deletions

2
package-lock.json generated
View File

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

View File

@ -1,6 +1,6 @@
{
"name": "@gitzone/tsbundle",
"version": "1.0.33",
"version": "1.0.35",
"private": false,
"description": "a bundler using rollup for painless bundling of web projects",
"main": "dist/index.js",

View File

@ -2,49 +2,15 @@ import * as plugins from './tsbundle.plugins';
import { logger } from './tsbundle.logging';
export class TsBundle {
public optionsTest: plugins.rollup.RollupOptions = this.getBaseOptions();
public optionsProduction: plugins.rollup.RollupOptions = (() => {
const productionOptions = this.getBaseOptions();
productionOptions.plugins.push(plugins.rollupTerser());
return productionOptions;
})();
constructor() {}
/**
* creates a bundle for the test enviroment
*/
public async buildTest() {
// create a bundle
logger.log('info', `bundling for TEST!`);
const bundle = await plugins.rollup.rollup(this.optionsTest);
bundle.generate(this.optionsTest.output);
await bundle.write(this.optionsTest.output);
logger.log('ok', `Successfully bundled files!`);
}
/**
* creates a bundle for the production environment
*/
public async buildProduction() {
// create a bundle
logger.log('info', `bundling for PRODUCTION!`);
const bundle = await plugins.rollup.rollup(this.optionsProduction);
bundle.generate(this.optionsProduction.output);
await bundle.write(this.optionsProduction.output);
logger.log('ok', `Successfully bundled files!`);
}
/**
* the basic default options for rollup
*/
public getBaseOptions() {
public getBaseOptions(fromArg: string = `ts_web/index.ts`, toArg: string = 'dist_web/bundle.js') {
const baseOptions: plugins.rollup.RollupOptions = {
input: `ts_web/index.ts`,
input: fromArg,
output: {
name: 'tsbundle',
// file: 'dist_web/bundle.js',
file: 'dist_web/bundle.js',
file: toArg,
format: 'iife',
sourcemap: true
},
@ -82,7 +48,7 @@ export class TsBundle {
// Resolve source maps to the original source
plugins.rollupSourceMaps(),
plugins.rollupBabel({
/*plugins.rollupBabel({
runtimeHelpers: true,
extensions: ['.js', '.jsx', '.ts', '.tsx'],
babelrc: false,
@ -105,9 +71,45 @@ export class TsBundle {
}
]
]
})
})*/
]
};
return baseOptions;
}
public getOptionsTest(fromArg: string, toArg: string): plugins.rollup.RollupOptions {
return this.getBaseOptions();
}
public getOptionsProduction(fromArg: string, toArg: string): plugins.rollup.RollupOptions {
const productionOptions = this.getBaseOptions();
productionOptions.plugins.push(plugins.rollupTerser());
return productionOptions;
}
constructor() {}
/**
* creates a bundle for the test enviroment
*/
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);
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 bundle = await plugins.rollup.rollup(this.getOptionsProduction(fromArg, toArg));
bundle.generate(this.getOptionsProduction(fromArg, toArg).output);
await bundle.write(this.getOptionsProduction(fromArg, toArg).output);
logger.log('ok', `Successfully bundled files!`);
}
}

View File

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