Skip to content

Instantly share code, notes, and snippets.

@iamturns
Created January 14, 2019 07:21
Show Gist options
  • Save iamturns/e77b336224b413e367f3ab6fbe50ef8c to your computer and use it in GitHub Desktop.
Save iamturns/e77b336224b413e367f3ab6fbe50ef8c to your computer and use it in GitHub Desktop.
Rollup
import autoExternal from "rollup-plugin-auto-external"
import babel from "rollup-plugin-babel"
import commonjs from "rollup-plugin-commonjs"
import nodeBuiltins from "rollup-plugin-node-builtins"
import nodeGlobals from "rollup-plugin-node-globals"
import nodeResolve from "rollup-plugin-node-resolve"
import pkg from "./package.json"
const SRC_EXTENSIONS = [".js", ".jsx", ".ts", ".tsx"]
module.exports = {
input: pkg.source,
plugins: [
// Exclude dependencies listed in package.json
autoExternal(),
// __dirname, __filename, etc
nodeGlobals(),
// path, fs, process, etc
nodeBuiltins(),
// Resolve some extra file extensions
nodeResolve({ extensions: SRC_EXTENSIONS }),
// Rollup only understands esm by default
commonjs(),
// Compile files with Babel
babel({
extensions: SRC_EXTENSIONS,
include: ["src/**/*"],
}),
],
output: [
{
file: pkg.main,
format: "cjs",
sourcemap: true,
},
{
file: pkg.module,
format: "esm",
sourcemap: true,
},
{
file: pkg.browser,
format: "iife",
sourcemap: true,
name: "ExampleApp",
// External modules here
globals: {},
},
],
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment