From cb7fbcf33e8208ba295ada18f90e44b504be8a98 Mon Sep 17 00:00:00 2001 From: Niklas von Hertzen Date: Fri, 6 Jul 2018 22:28:30 +0800 Subject: [PATCH] Begin implementing rollup --- package.json | 7 +++++++ rollup.config.js | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 rollup.config.js diff --git a/package.json b/package.json index 9dfbf52..038ff82 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "babel-eslint": "7.2.3", "babel-loader": "7.1.1", "babel-plugin-dev-expression": "0.2.1", + "babel-plugin-external-helpers": "^6.22.0", "babel-plugin-transform-es2015-modules-commonjs": "6.26.0", "babel-plugin-transform-object-rest-spread": "6.23.0", "babel-preset-es2015": "6.24.1", @@ -56,6 +57,11 @@ "promise-polyfill": "6.0.2", "replace-in-file": "^3.0.0", "rimraf": "2.6.1", + "rollup": "0.57.1", + "rollup-plugin-babel": "^3.0.3", + "rollup-plugin-commonjs": "^9.1.0", + "rollup-plugin-node-resolve": "^3.3.0", + "rollup-plugin-uglify": "^3.0.0", "serve-index": "1.9.0", "slash": "1.0.0", "uglifyjs-webpack-plugin": "^1.1.2", @@ -65,6 +71,7 @@ "build": "rimraf dist/ && node scripts/create-reftest-list && npm run build:npm && npm run build:browser", "build:npm": "babel src/ -d dist/npm/ --plugins=dev-expression,transform-es2015-modules-commonjs && replace-in-file __VERSION__ '\"$npm_package_version\"' dist/npm/index.js", "build:browser": "webpack", + "rollup": "rollup -c", "format": "prettier --single-quote --no-bracket-spacing --tab-width 4 --print-width 100 --write \"{src,www/src,tests,scripts}/**/*.js\"", "flow": "flow", "lint": "eslint src/**", diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..64f5ddc --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,38 @@ +/* @flow */ +'use strict'; + +const fs = require('fs'); +const path = require('path'); +const pkg = JSON.parse(fs.readFileSync(path.resolve(__dirname, 'package.json'))); + +const banner = + `/* +${pkg.title} ${pkg.version} <${pkg.homepage}> +Copyright (c) ${(new Date()).getFullYear()} ${pkg.author.name} <${pkg.author.url}> +Released under ${pkg.license} License +*/`; + +import babel from 'rollup-plugin-babel'; +import commonjs from 'rollup-plugin-commonjs'; +import resolve from 'rollup-plugin-node-resolve'; + +export default { + input: './src/index.js', + plugins: [ + resolve(), + babel({ + exclude: 'node_modules/**' + }), + commonjs({ + namedExports: { + 'node_modules/css-line-break/dist/index.js': ['toCodePoints', 'fromCodePoint', 'LineBreaker'] + } + }) + ], + output: { + file: './dist/html2canvas.js', + name: 'html2canvas', + format: 'umd', + banner + } +};