From e31fd5ff8e15cf436e06b9389cc1865a4bab14a3 Mon Sep 17 00:00:00 2001 From: Raymond Cohen Date: Sat, 24 Feb 2018 07:49:15 -0500 Subject: [PATCH] enable sourcemaps in rollup config --- README.md | 16 ++++++++++++++++ rollup.config.js | 6 ++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 01032af..a91290f 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ There are some existing React library boilerplates, but none of them fulfilled t - Support importing CSS in your components (with css modules enabled by default) - Note that CSS support will be a noop if you're using css-in-js - Testing with [Jest](https://facebook.github.io/jest/), using `react-scripts` from `create-react-app` +- Sourcemap creation enabled by default - Thorough documentation written by someone who cares :heart_eyes: ## Walkthrough @@ -111,6 +112,21 @@ Here is a [branch](https://github.com/transitive-bullshit/react-modern-library-b Here is a [branch](https://github.com/transitive-bullshit/react-modern-library-boilerplate/tree/feature/material-ui) which demonstrates how to create a module that makes use of a relatively complicated peer dependency, [material-ui](https://github.com/mui-org/material-ui). It shows the power of [rollup-plugin-peer-deps-external](https://www.npmjs.com/package/rollup-plugin-peer-deps-external) which makes it a breeze to create reusable modules that include complicated material-ui subcomponents without having them bundled as a part of your module. +## Sourcemaps + +Sourcemaps are enabled in `rollup.config.js` resulting in `.map` files when you run a build: + +``` +dist/index.es.js +dist/index.es.js.map +dist/index.js +dist/index.js.map +``` + +The [sourcemap config option](https://rollupjs.org/guide/en#big-list-of-options) can also be set to `'inline'` to get sourcemaps appended inside the `.js` files themselves. + +Note: create-react-app does not currently use the (source-map-loader)[https://github.com/webpack-contrib/source-map-loader] plugin, so it will not include sourcemaps from dependencies in the final build. See https://github.com/facebook/create-react-app/pull/2355 for updates. + ## License MIT © [Travis Fischer](https://github.com/transitive-bullshit) diff --git a/rollup.config.js b/rollup.config.js index 84ca386..734b544 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -11,11 +11,13 @@ export default { output: [ { file: pkg.main, - format: 'cjs' + format: 'cjs', + sourcemap: true }, { file: pkg.module, - format: 'es' + format: 'es', + sourcemap: true } ], plugins: [