Skip to content

Instantly share code, notes, and snippets.

@ivan-demchenko
Created October 15, 2019 19:37
Show Gist options
  • Save ivan-demchenko/2063bb40bfe707296e9c0790d86c2877 to your computer and use it in GitHub Desktop.
Save ivan-demchenko/2063bb40bfe707296e9c0790d86c2877 to your computer and use it in GitHub Desktop.
Rollup for React with TypeScript and SVG icons
{
"devDependencies": {
"@svgr/rollup": "^4.3.3",
"@types/react": "^16.9.7",
"@types/react-dom": "^16.9.2",
"rollup": "^1.24.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-filesize": "^6.2.1",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-terser": "^5.1.2",
"rollup-plugin-typescript2": "^0.24.3",
"typescript": "^3.6.4"
},
"dependencies": {
"react": "^16.10.2",
"react-dom": "^16.10.2"
}
}
import typescript from 'rollup-plugin-typescript2';
import svgr from '@svgr/rollup';
import { terser } from "rollup-plugin-terser";
import filesize from 'rollup-plugin-filesize';
export default {
input: './src/index.tsx',
output: {
format: 'esm',
dir: './dist',
sourcemap: true
},
plugins: [
typescript({
objectHashIgnoreUnknownHack: true
}),
svgr(),
terser(),
filesize()
]
}
import React from 'react';
import Pumpkin from './icon.svg';
export const App = () => (
<div>
<h1>Hello!</h1>
<Pumpkin />
</div>
);
declare module "*.svg" {
const content: any;
export default content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment