Skip to content

Commit

Permalink
build(crypto): configure rollup (#2853)
Browse files Browse the repository at this point in the history
  • Loading branch information
air1one authored and faustbrian committed Aug 2, 2019
1 parent 16a15e0 commit 6515a93
Show file tree
Hide file tree
Showing 3 changed files with 172 additions and 1,844 deletions.
10 changes: 8 additions & 2 deletions packages/crypto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
],
"main": "dist/index",
"module": "dist/index",
"browser": "dist/index",
"browser": "dist/index-browser",
"types": "dist/index",
"scripts": {
"build": "yarn clean && tsc",
"build:rollup": "yarn clean && tsc && rollup -c",
"build:watch": "yarn clean && yarn compile -w",
"clean": "del dist",
"compile": "../../node_modules/typescript/bin/tsc",
Expand Down Expand Up @@ -60,7 +61,12 @@
"@types/node-forge": "^0.8.4",
"@types/otplib": "^7.0.0",
"@types/pluralize": "^0.0.29",
"@types/wif": "^2.0.1"
"@types/wif": "^2.0.1",
"rollup": "^1.17.0",
"rollup-plugin-terser": "^5.1.1",
"rollup-plugin-commonjs": "^10.0.1",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-resolve": "^5.2.0"
},
"publishConfig": {
"access": "public"
Expand Down
47 changes: 47 additions & 0 deletions packages/crypto/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import pkg from "./package.json";
import { terser } from "rollup-plugin-terser";
import commonjs from "rollup-plugin-commonjs";
import nodeResolve from "rollup-plugin-node-resolve";
import json from "rollup-plugin-json";

export default {
input: "dist/index.js", // our source file
output: [
{
file: pkg.main,
format: "cjs"
},
{
file: pkg.module,
format: "es" // the preferred format
},
{
file: pkg.browser,
format: "iife",
name: "ArkCrypto" // the global which can be used in a browser
}
],
external: [
...Object.keys(pkg.dependencies || {})
],
plugins: [
json({
// for tree-shaking, properties will be declared as
// variables, using either `var` or `const`
preferConst: true, // Default: false

// ignores indent and generates the smallest code
compact: true, // Default: false
}),
nodeResolve({
jsnext: true,
main: true
}),
commonjs({
namedExports: {
"dist/index.js": ["__moduleExports"]
}
}),
terser() // minifies generated bundles
]
};
Loading

0 comments on commit 6515a93

Please sign in to comment.