Skip to content

Instantly share code, notes, and snippets.

@baorv
Created August 23, 2018 06:38
Show Gist options
  • Select an option

  • Save baorv/7e380379619b61e0012c7659c2f255d5 to your computer and use it in GitHub Desktop.

Select an option

Save baorv/7e380379619b61e0012c7659c2f255d5 to your computer and use it in GitHub Desktop.
Rollup configuration for production
import babel from "rollup-plugin-babel";
import resolve from "rollup-plugin-node-resolve";
import postcss from "rollup-plugin-postcss";
import commonjs from "rollup-plugin-commonjs";
import copy from "rollup-plugin-copy-assets";
import progress from "rollup-plugin-progress";
import visualizer from "rollup-plugin-visualizer";
import filesize from "rollup-plugin-filesize";
let external = [
"react",
"@shopify/polaris",
"prop-types",
"@shopify/react-utilities",
"react-perfect-scrollbar",
"react-dom",
"validator",
"react-rte",
"warning",
"invariant",
"@shopify/javascript-utilities/other",
"babel-runtime/helpers/classCallCheck",
"babel-runtime/helpers/createClass",
"@shopify/javascript-utilities/events",
"@shopify/javascript-utilities/geometry",
"lodash-decorators/throttle"
];
export default {
input: "src/polaris.js",
plugins: [
babel(
{
babelrc: false,
include: "src/**/*.js",
exclude: [
"node_modules/**"
],
presets: [["env", {modules: false}], "react", "es2015-rollup"],
plugins: ["transform-object-rest-spread", "transform-class-properties", "external-helpers", "transform-runtime"],
runtimeHelpers: true,
externalHelpers: false
}
),
resolve({
jsnext: true,
main: true,
browser: true,
}),
postcss({
modules: false,
extract: "dist/polaris.css",
inject: false,
extensions: [".css"],
sourceMap: "inline"
}),
commonjs(),
copy({
assets: [
"./src/polaris.scss",
"./src/styles/"
]
}),
progress(),
visualizer(),
filesize(),
],
external: external,
output: [
{
file: "dist/polaris.js",
format: "cjs",
moduleName: "polaris",
sourceMap: true
},
{
file: "dist/polaris.es.js",
format: "es",
moduleName: "polaris",
sourceMap: true
}
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment