Created
October 15, 2019 19:37
-
-
Save ivan-demchenko/2063bb40bfe707296e9c0790d86c2877 to your computer and use it in GitHub Desktop.
Rollup for React with TypeScript and SVG icons
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import Pumpkin from './icon.svg'; | |
export const App = () => ( | |
<div> | |
<h1>Hello!</h1> | |
<Pumpkin /> | |
</div> | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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