Skip to content

Commit

Permalink
feat: add terser to minify generated bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardssh committed Dec 22, 2021
1 parent 71c5265 commit d441b28
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"prettier": "^2.5.1",
"pretty-quick": "^3.1.3",
"rollup": "^2.61.1",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.31.1",
"rollup-plugin-version-injector": "^1.3.3",
"typescript": "^4.5.4"
Expand Down
58 changes: 57 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions scripts/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@ import path from 'path';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import typescriptPlugin from 'rollup-plugin-typescript2';
import versionInjector from 'rollup-plugin-version-injector';
import { terser } from 'rollup-plugin-terser';
import minimist from 'minimist';

const args = minimist(process.argv.slice(2));
const isProduction = args.configProduction;
import pkg from '../package.json';

const umdOutput = 'dist/rage-rpc.umd.js';
const productionMode = isProduction
? terser({
keep_classnames: true,
keep_fnames: true,
output: {
comments: false
}
})
: [];

const onwarn = (msg, warn) => {
if (!/Circular|The 'this' keyword/.test(msg)) {
Expand Down Expand Up @@ -58,7 +67,8 @@ function createConfig(output) {
fileRegexp: /\.(js|mjs|html|css)$/
},
injectInComments: false
})
}),
productionMode
],
inlineDynamicImports: true,
onwarn
Expand Down

0 comments on commit d441b28

Please sign in to comment.