Skip to content

Instantly share code, notes, and snippets.

@cuibonobo
Forked from bcherny/react-rollup-typescript.md
Created August 20, 2019 14:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cuibonobo/d9d3c6a66e8a65df2abbdbcbe1474069 to your computer and use it in GitHub Desktop.
Save cuibonobo/d9d3c6a66e8a65df2abbdbcbe1474069 to your computer and use it in GitHub Desktop.
react + rollup + typescript boilerplate

terminal:

npm i --save-dev rollup rollup-watch rollup-plugin-typescript typescript typings
npm i -S react react-dom
./node_modules/.bin/typings install react react-dom --save
mkdir src dist
touch src/index.tsx

package.json:

"scripts": {
  "build": "rollup -c",
  "watch": "rollup -cw"
}

rollup.config.js:

import typescript from 'rollup-plugin-typescript'

export default {
  entry: './src/index.tsx',
  dest: './dist/bundle.js',
  format: 'iife',
  plugins: [
    typescript()
  ]
}

tsconfig.json:

{
  "compilerOptions": {
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "forceConsistentCasingInFileNames": true,
    "jsx": "react",
    "module": "es6",
    "moduleResolution": "node",
    "noImplicitAny": true,
    "outDir": "./dist",
    "preserveConstEnums": true,
    "target": "es5"
  },
  "exclude": [
    "node_modules"
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment