From b4adb4ce27b08030353f767f2ac6901eff2b0931 Mon Sep 17 00:00:00 2001 From: Luca Ban Date: Sun, 11 Aug 2019 22:53:26 +0900 Subject: [PATCH] docs: add info on installing locally (#2995) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add info how to install locally Fixes #2720 * typo 🦋 * change "./node_modules/.bin/rollup" with "rollup" 💎 * change `npm run` with `npx` 🙈 * docs: update verbiage and apply suggestions --- docs/04-tutorial.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/docs/04-tutorial.md b/docs/04-tutorial.md index acbe9930ddb..73b3e811300 100755 --- a/docs/04-tutorial.md +++ b/docs/04-tutorial.md @@ -127,6 +127,46 @@ rollup --config rollup.config.dev.js rollup --config rollup.config.prod.js ``` +### Installing Rollup locally + +When working within teams or distributed environments it can be wise to add Rollup as a _local_ dependency. Installing Rollup locally prevents the requirement that multiple contributors install Rollup separately as an extra step, and ensures that all contributors are using the same version of Rollup. + +To install Rollup locally with NPM: + +```console +npm install rollup --save-dev +``` + +Or with Yarn: + +```console +yarn -D add rollup +``` + +After installing, Rollup can be run within the root directory of your project: + +```console +npx rollup --config +``` + +Or with Yarn: + +```console +yarn rollup --config +``` + +Once installed, it's common practice to add a single build script to `package.json`, providing a convenient command for all contributors. e.g. + +```json +{ + "scripts": { + "build": "rollup --config" + } +} +``` + +_Note: Once installed locally, both NPM and Yarn will resolve the dependency's bin file and execute Rollup when called from a package script._ + ### Using plugins So far, we've created a simple bundle from an entry point and a module imported via a relative path. As you build more complex bundles, you'll often need more flexibility – importing modules installed with NPM, compiling code with Babel, working with JSON files and so on.