Skip to content

Commit

Permalink
feat: adding rollup bundling for cdn usage
Browse files Browse the repository at this point in the history
  • Loading branch information
StiliyanKushev committed Dec 22, 2023
1 parent fb4ab89 commit beed7be
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ tensorboard/**
Dockerfile
.pre
.out
.cdn
docs
firebase-key.json
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
.pre
.out
.cdn
tensorboard/**
docs
firebase-key.json
1 change: 1 addition & 0 deletions lib/.npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
*
!.out/**
!.cdn/**
!assets/**
!package.json
!package-lock.json
Expand Down
8 changes: 7 additions & 1 deletion lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,11 @@
"typings": ".out/lib/index.d.ts",
"scripts": {},
"author": "StiliyanKushev",
"license": "ISC"
"license": "ISC",
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"rollup": "^2.79.1",
"rollup-plugin-terser": "^7.0.2"
}
}
13 changes: 13 additions & 0 deletions lib/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import { terser } from 'rollup-plugin-terser';

export default {
input: '.out/lib/index.js',
output: {
file: '.cdn/bundle.min.js',
format: 'iife',
name: 'AiMR_GAN'
},
plugins: [commonjs(), resolve(), terser()]
};
11 changes: 11 additions & 0 deletions scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ registerCommand('clean.root.bin', () => {
registerCommand('clean.lib', () => {
console.log('Cleaning lib folder...');
rm('./lib/.out');
rm('./lib/.cdn');
rm('./lib/README.md');
rm('./lib/assets');
});
Expand Down Expand Up @@ -238,6 +239,15 @@ registerCommand('prepare.bin', () => {
exec('npm ci', { cwd: './src' });
});

/**
* @summary
* Takes care of bundling the library so it can be
* published to a cdn in addition to npm.
*/
registerCommand('bundle.lib', () => {
exec('npx rollup -c', { cwd: './lib' });
});

/**
* @summary
* Builds the library of the module and packs it into a .tgz,
Expand All @@ -249,6 +259,7 @@ registerCommand('build.lib', () => {
console.log('Building the packed library...');
exec('npx tsc -p ./tsconfig.json', { cwd: './lib' });
exec('npx gulp lib.postprocessing.out', { cwd: './lib', stdio: 'pipe' });
executeCommand('bundle.lib');

/**
* @note copy the root README.md to the package (used by npm)
Expand Down

0 comments on commit beed7be

Please sign in to comment.