Skip to content

Instantly share code, notes, and snippets.

@ArvinH
Forked from bcherny/react-rollup-typescript.md
Created October 23, 2021 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArvinH/af51754c320a84778127066d5febbda5 to your computer and use it in GitHub Desktop.
Save ArvinH/af51754c320a84778127066d5febbda5 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