const uglifyPlugin = require("rollup-plugin-uglify");
const replace = require("rollup-plugin-replace");
const commonjs = require("rollup-plugin-commonjs");
const resolve = require("rollup-plugin-node-resolve");

module.exports = function(options, env) {
  const {
    name,
    file,
    input,
    external = [],
    globals = {},
    format = "cjs",
    plugins: userPlugins = [],
    sourcemap = false,
    safeModules = true,
    uglify = false
  } = options;

  const replacePatterns = {
    // Typescript -> Uglify
    "@class": "#__PURE__"
  };
  if (safeModules) {
    console.log("BUILDING WITH", env.NODE_ENV);
    replacePatterns["process.env.NODE_ENV"] = JSON.stringify(env.NODE_ENV);
  }

  const plugins = [
    ...userPlugins,
    replace(replacePatterns),
    resolve(),
    commonjs({
      include: /node_modules/
    })
  ];

  if (uglify) {
    plugins.push(uglifyPlugin());
  }

  return {
    inputOptions: {
      input,
      external,
      plugins
    },
    outputOptions: {
      name,
      format,
      file,
      sourcemap,
      globals
    }
  };
};

const uglifyPlugin = require("rollup-plugin-uglify");
const replace = require("rollup-plugin-replace");
const commonjs = require("rollup-plugin-commonjs");
const resolve = require("rollup-plugin-node-resolve");

module.exports = function(options, env) {
  const {
    name,
    file,
    input,
    external = [],
    globals = {},
    format = "cjs",
    plugins: userPlugins = [],
    sourcemap = false,
    safeModules = true,
    uglify = false
  } = options;

  const replacePatterns = {
    // Typescript -> Uglify
    "@class": "#__PURE__"
  };
  if (safeModules) {
    replacePatterns["process.env.NODE_ENV"] = JSON.stringify(env.NODE_ENV);
  }

  const plugins = [
    ...userPlugins,
    replace(replacePatterns),
    resolve(),
    commonjs({
      include: /node_modules/
    })
  ];

  if (uglify) {
    plugins.push(uglifyPlugin());
  }

  return {
    inputOptions: {
      input,
      external,
      plugins
    },
    outputOptions: {
      name,
      format,
      file,
      sourcemap,
      globals
    }
  };
};

Remove log from build script
Remove log from build script
