From d82841119820b4814169a8fa42a88f166f406a6f Mon Sep 17 00:00:00 2001 From: Michal Wolny Date: Tue, 6 Oct 2020 19:28:20 +0200 Subject: [dev-icons-react-bundling] change svgr template to enable babel transformation, add babel with react and env, add rollup for commonJS, UMD and ESM, add gulp and npm tasks for building react, add peer react and react-dom dependencies, add needed deps, updated npm package files, updated readme --- rollup.config.js | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 rollup.config.js (limited to 'rollup.config.js') 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, + }, +]; -- cgit v1.2.1