UNPKG

scandit-sdk

Version:

Scandit Barcode Scanner SDK for the Web

183 lines (176 loc) 4.82 kB
// rollup.min-config.js import os from "os"; import path from "path"; import autoprefixer from "autoprefixer"; import babel from "rollup-plugin-babel"; import commonjs from "rollup-plugin-commonjs"; import cssnano from "cssnano"; import nodeResolve from "rollup-plugin-node-resolve"; import nodeSass from "node-sass"; import postcss from "postcss"; import filesize from "rollup-plugin-filesize"; import sass from "rollup-plugin-sass"; import sizes from "rollup-plugin-sizes"; import sourcemaps from "rollup-plugin-sourcemaps"; import { terser } from "rollup-plugin-terser"; import typescript from "rollup-plugin-typescript2"; import visualizer from "rollup-plugin-visualizer"; import { version } from "./package.json"; const config = { input: "src/index.ts", output: { sourcemap: true, banner: `/*! * @license * * Scandit Barcode Scanner SDK for the Web * v. ${version} * * Copyright © 2019 Scandit AG. All Rights Reserved. * * The use of this software is governed by the Scandit Terms and Conditions. * https://ssl.scandit.com/terms/test.pdf * * The following sets forth attribution notices for third party software that may be contained in portions of the product. * https://docs.scandit.com/stable/web/LICENSE */` }, plugins: [ nodeResolve({ mainFields: ["module", "main", "browser"] }), commonjs({ namedExports: { "node_modules/eventemitter3/index.js": ["EventEmitter"] } }), sass({ insert: true, runtime: nodeSass, processor: css => { return postcss([autoprefixer, cssnano]) .process(css, { from: undefined }) .then(result => { return result.css; }); } }), typescript({ tsconfig: "./tsconfig.module.json", typescript: require("typescript"), cacheRoot: "./node_modules/.cache/.rts2_cache/" + process.env.CACHE_FOLDER, useTsconfigDeclarationDir: true, clean: process.env.ROLLUP_MODE === "size-info", objectHashIgnoreUnknownHack: process.env.ROLLUP_MODE === "size-info" }), babel({ extensions: [".js", ".jsx", ".ts", ".tsx"], presets: [ [ "@babel/preset-env", { modules: false } ] ], plugins: [ [ "@babel/plugin-transform-runtime", { corejs: 2 } ] ], overrides: [ { test: "**/engineWorker.ts", presets: [ [ "@babel/preset-env", { targets: { browsers: [ "Chrome >= 57", "ChromeAndroid >= 59", "Firefox >= 52", "FirefoxAndroid >= 55", "Opera >= 44", "OperaMobile >= 46", "Safari >= 11", "iOS >= 11", "Edge >= 16", "Samsung >= 7" ] }, modules: false, include: [ "transform-template-literals", "transform-function-name", "transform-arrow-functions", "transform-parameters" ], exclude: ["transform-typeof-symbol", "transform-for-of"] } ] ], plugins: [ [ "@babel/plugin-transform-runtime", { corejs: false, helpers: false, regenerator: false } ] ] } ], babelrc: false, runtimeHelpers: true, exclude: "node_modules/**" }) ], onwarn: function(message) { if (/Circular dependency:/.test(message)) { return; } if (/The "ongenerate" hook used by plugin rollup-plugin-sizes is deprecated./.test(message)) { return; } if (/The \'this\' keyword is equivalent to \'undefined\' at the top level of an ES module/.test(message)) { return; } console.error(message); } }; if (process.env.ROLLUP_MODE === "size-info") { config.plugins.push(sizes()); config.plugins.push(filesize()); config.plugins.push( visualizer({ filename: path.join(os.tmpdir(), "size-info.html"), open: true, title: "WebSDK Bundle Size", template: "sunburst" }) ); } if (process.env.ROLLUP_MODE === "minify") { config.plugins.push( terser({ warnings: true, output: { comments: /Scandit Barcode Scanner SDK for the Web/i }, compress: { passes: 3 } }) ); config.plugins.push(sourcemaps()); } else { config.plugins.push(sourcemaps()); } export default config;