UNPKG

@brixtol/rollup-config

Version:

Shared Rollup configuration interface used within the Brixtol Textiles monorepo.

77 lines 8.44 kB
{ "name": "@brixtol/rollup-config", "version": "1.5.5", "description": "Shared Rollup configuration interface used within the Brixtol Textiles monorepo.", "keywords": [ "rollup", "rollup-plugin", "config", "brixtol" ], "homepage": "https://github.com/brixtol/rollup-config", "author": { "name": "Νίκος Σαβίδης ", "email": "n@brixtol.com", "url": "https://brixtoltextiles.com" }, "license": "MIT", "type": "module", "types": "./index.d.ts", "exports": "./index.js", "repository": { "type": "git", "url": "https://github.com/brixtol/rollup-config" }, "bugs": { "url": "https://github.com/brixtol/rollup-config" }, "prettier": "@brixtol/prettier-config", "eslintConfig": { "ignorePatterns": [ "index.js", "index.d.ts" ], "extends": "@brixtol/eslint-config" }, "dependencies": { "@brixtol/rollup-html": "0.5.1", "@brixtol/rollup-utils": "1.2.1", "@rollup/plugin-alias": "^3.1.9", "@rollup/plugin-beep": "^0.2.0", "@rollup/plugin-commonjs": "^21.0.3", "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-multi-entry": "^4.1.0", "@rollup/plugin-node-resolve": "^13.2.0", "@rollup/plugin-replace": "^4.0.0", "rollup-plugin-browsersync": "^1.3.3", "rollup-plugin-copy": "^3.4.0", "rollup-plugin-delete": "^2.0.0", "rollup-plugin-dts": "^4.2.1", "rollup-plugin-esbuild": "^4.9.1", "rollup-plugin-filesize": "^9.1.2", "rollup-plugin-node-polyfills": "^0.2.1", "rollup-plugin-postcss": "^4.0.2", "rollup-plugin-terser": "^7.0.2", "rollup-plugin-ts-paths": "^1.0.5" }, "devDependencies": { "@brixtol/eslint-config": "1.2.1", "@brixtol/prettier-config": "1.2.1", "@brixtol/tsconfig": "1.2.0", "@types/browser-sync": "^2.26.3", "estree-walker": "^3.0.1", "ts-essentials": "^9.1.2" }, "optionalDependencies": { "autoprefixer": "^10.4.4", "esbuild": "^0.14.36", "postcss": "^8.4.12", "rollup": "^2.70.1", "typescript": "^4.6.3" }, "scripts": { "dev": "tsc --watch", "build": "tsc" }, "readme": "# @brixtol/rollup-config\n\nShareable rollup configuration used within the [Brixtol Textiles](https://brixtoltextiles.com) monorepo. The module acts as an interface, exporting an instance of Rollup and several plugins that are frequently used by packages contained across the workspace. Each plugin is wrapped as a getter which helps negate exposing unused plugins on the export.\n\n### Why\n\nWe operate atop of a cloud driven serverless architecture. This module assists in the processes relating to our cloud builds, serverless apis, open/closed sourced package and applications using Lambdas or edge handlers. It provides us a single dependency import for bundling with Rollup and single source for version controlling all plugins we leverage.\n\n### Rollup + ESBuild\n\nBundles are generated using ESBuild together will Rollup. TypeScript and JavaScript modules are processed with [esbuild](https://esbuild.github.io/) using [rollup-plugin-esbuild](https://github.com/egoist/rollup-plugin-esbuild).\n\n# Install\n\nThis module can be installed and leveraged by projects that are outside of our organization.\n\n[pnpm](https://pnpm.js.org/en/cli/install)\n\n```cli\npnpm add @brixtol/rollup-config -save-dev\n```\n\n### Brixtol Monorepo\n\nIf you are working within the Brixtol Textiles monorepo then please note that this module is installed at root, so for development on **private** modules it does not need to be installed. If a project is **public** facing or consumed in build images elsewhere then you will need to explicitly install it.\n\n> Use `workspace:*` for version definition to ensure packages are always using the latest.\n\n# Usage\n\nThis is an ESM module, your rollup config file must use a `.mjs` extension (`rollup.config.mjs`) or else Node will complain depending on your project presets. The `rollup()` export is totally optional, its a re-export of `defineConfig` and used to provide type completions.\n\n<!-- prettier-ignore -->\n```ts\nimport { rollup, env, plugin } from \"@brixtol/rollup-config\";\n\nexport default rollup(\n {\n input: \"src/file.ts\",\n output: {\n format: 'cjs',\n dir: 'package',\n sourcemap: env.is('dev', 'inline'), // Inline sourcemap in development else false\n interop: 'default'\n },\n plugins: env.if('div')(\n [\n plugin.esbuild(options: {}),\n // etc etc\n ]\n )(\n [\n plugin.terser()\n ]\n )\n }\n);\n```\n\n> Types are re-exported and provided for all plugins which support them. Rollup configuration files within our workspace.\n\n### What is the `env.if()` method?\n\nThis module provides exports from [@brixtol/rollup-utils](https://github.com/BRIXTOL/rollup-utils). The `env.if()` allows us to use single file for development and production bundles. When an `--environment` flag is passed with a of value of `prod` the plugins are concatenated, so first curried parameter is combined with the second curried parameter, which should both be an array list of plugins[].\n\nThe `dev` is default, so running `rollup -c -w` results in:\n\n<!-- prettier-ignore -->\n```ts\nenv.if('dev')([ plugin.commonjs(), plugin.ts() ])([ plugin.terser() ])\n// => [ commonjs(), ts() ]\n```\n\nIf you run `rollup -c --environment prod` it results in:\n\n<!-- prettier-ignore -->\n```ts\nenv.if('dev')([ plugin.commonjs(), plugin.ts() ])([ plugin.terser() ])\n// => [ commonjs(), ts(), terser() ]\n```\n\n### Plugins\n\nAll plugins are available via the named `plugin` export. In addition to the plugins rollup's `defineConfig` function is exported as `rollup` namespace so configuration options have typings on the default export. Below is the complete list of included plugins:\n\n| Export | Plugin |\n| ------------------- | ------------------------------------------------------------------ |\n| `plugin.alias` | [@rollup/plugin-alias](https://git.io/JuTc9) |\n| `plugin.beep` | [@rollup/plugin-beep](https://git.io/JuTEW) |\n| `plugin.bs` | [rollup-plugin-browsersync](https://git.io/JXjkK) |\n| `plugin.copy` | [rollup-plugin-copy](https://git.io/JuTux) |\n| `plugin.commonjs` | [@rollup/plugin-commonjs](https://git.io/JuTcI) |\n| `plugin.del` | [rollup-plugin-delete](https://git.io/JuTz3) |\n| `plugin.esbuild` | [rollup-plugin-esbuild](https://github.com/evanw/esbuild) |\n| `plugin.filesize` | [rollup-plugin-filesize](https://git.io/JuTzw) |\n| `plugin.html` | [@brixtol/rollup-html](https://github.com/brixtol/rollup-html) |\n| `plugin.json` | [@rollup/plugin-json](https://git.io/JuTni) |\n| `plugin.livereload` | [rollup-plugin-livereload](https://git.io/JuTu8) |\n| `plugin.multi` | [@rollup/plugin-multi-entry](https://git.io/JwRT2) |\n| `plugin.polyfills` | [rollup-plugin-node-polyfills](https://git.io/JuTuV) |\n| `plugin.resolve` | [@rollup/plugin-node-resolve](https://git.io/JOqCR) |\n| `plugin.postcss` | [rollup-plugin-postcss](https://git.io/JuEZg) |\n| `plugin.replace` | [@rollup/plugin-replace](https://git.io/JuTcC) |\n| `plugin.dts` | [rollup-plugin-dts](https://github.com/Swatinem/rollup-plugin-dts) |\n| `plugin.serve` | [rollup-plugin-serve](https://git.io/JuTuq) |\n| `plugin.terser` | [rollup-plugin-terser](https://git.io/JuTz5) |\n\n### Optional Dependencies\n\nThe module includes several optional dependencies, one being Rollup itself. Ensure that if you are using a plugin you install any optional it might require.\n\n- [Autoprefixer](https://github.com/postcss/autoprefixer)\n- [PostCSS](https://github.com/postcss/postcss)\n- [Rollup](https://rollupjs.org/guide/en/)\n- [TypeScript](https://www.typescriptlang.org/)\n\n### Related\n\n- [@brixtol/rollup-utils](https://github.com/BRIXTOL/rollup-utils)\n\n### License\n\nLicensed under [MIT](#LICENSE).\n\n---\n\nWe [♡](https://www.brixtoltextiles.com/discount/4D3V3L0P3RS]) open source!\n" }