aboutsummaryrefslogtreecommitdiff
path: root/rollup.config.js
diff options
context:
space:
mode:
authorPaweł Kuna <1282324+codecalm@users.noreply.github.com>2020-10-08 21:14:05 +0200
committerGitHub <noreply@github.com>2020-10-08 21:14:05 +0200
commitfa480759bd45f06341dc8026f3fb0f981965200c (patch)
tree5617b40088a57a19c74b454d949bbba5d3b63c63 /rollup.config.js
parentRelease 1.33.0 (diff)
parent[dev-icons-react-bundling] change svgr template to enable babel transformatio... (diff)
downloadtabler-icons-fa480759bd45f06341dc8026f3fb0f981965200c.tar.xz
Merge pull request #82 from tabler/dev-icons-react-bundling
React icons bundling for different usage types
Diffstat (limited to 'rollup.config.js')
-rw-r--r--rollup.config.js119
1 files changed, 119 insertions, 0 deletions
diff --git a/rollup.config.js b/rollup.config.js
new file mode 100644
index 00000000..bfcf4f3e
--- /dev/null
+++ b/rollup.config.js
@@ -0,0 +1,119 @@
+import resolve from "@rollup/plugin-node-resolve";
+import commonjs from "@rollup/plugin-commonjs";
+import filesize from "rollup-plugin-filesize";
+import babel from "@rollup/plugin-babel";
+import external from "rollup-plugin-peer-deps-external";
+import { terser } from "rollup-plugin-terser";
+import { uglify } from "rollup-plugin-uglify";
+import pkg from "./package.json";
+
+const input = "icons-react/index.js";
+
+const minifyExtension = (pathToFile) => pathToFile.replace(/\.js$/, ".min.js");
+
+const plugins = [
+ babel({
+ exclude: "node_modules/**",
+ }),
+ external(),
+ resolve(),
+ commonjs(),
+ filesize(),
+];
+
+const minCjsPlugins = [
+ babel({
+ exclude: "node_modules/**",
+ }),
+ external(),
+ resolve(),
+ commonjs(),
+ uglify(),
+ filesize(),
+];
+
+const minUmdEsmPlugins = [
+ babel({
+ exclude: "node_modules/**",
+ }),
+ external(),
+ resolve(),
+ commonjs(),
+ terser(),
+ filesize(),
+];
+
+export default [
+ // CommonJS (for Node)
+ {
+ input,
+ output: {
+ file: pkg.main,
+ format: "cjs",
+ sourcemap: true,
+ },
+ plugins,
+ },
+ // CommonJS (for Node) minified
+ {
+ input,
+ output: {
+ file: minifyExtension(pkg.main),
+ format: "cjs",
+ sourcemap: true,
+ },
+ plugins: minCjsPlugins,
+ },
+ // UMD (for browser)
+ {
+ input,
+ output: {
+ file: pkg.browser,
+ format: "umd",
+ sourcemap: true,
+ name: "tablerIcons",
+ globals: {
+ react: "React",
+ "react-dom": "ReactDOM",
+ },
+ },
+ plugins,
+ },
+ // UMD (for browser) minified
+ {
+ input,
+ output: {
+ file: minifyExtension(pkg.browser),
+ format: "umd",
+ sourcemap: true,
+ name: "tablerIcons",
+ globals: {
+ react: "React",
+ "react-dom": "ReactDOM",
+ },
+ },
+ plugins: minUmdEsmPlugins,
+ },
+ // ESM (for bundlers)
+ {
+ input,
+ output: {
+ file: pkg.module,
+ format: "es",
+ sourcemap: true,
+ exports: "named",
+ },
+ plugins,
+ },
+ // ESM (for bundlers) minified
+ {
+ input,
+ output: {
+ file: minifyExtension(pkg.module),
+ format: "es",
+ sourcemap: true,
+ exports: "named",
+ },
+ plugins: minUmdEsmPlugins,
+ },
+];