Skip to content

Instantly share code, notes, and snippets.

@ezekielchentnik
Created September 12, 2016 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ezekielchentnik/4db815ddab1f40224d6334383a72a568 to your computer and use it in GitHub Desktop.
Save ezekielchentnik/4db815ddab1f40224d6334383a72a568 to your computer and use it in GitHub Desktop.
const gobble = require('gobble')
const nodeResolve = require('rollup-plugin-node-resolve')
const commonjs = require('rollup-plugin-commonjs')
const replace = require('rollup-plugin-replace')
const babel = require('rollup-plugin-babel')
const uglify = require('rollup-plugin-uglify')
const autoprefixer = require('autoprefixer')
const cssnano = require('cssnano')
const pkg = require('./package')
const purifycss = require('purify-css')
const bundleSize = require('rollup-plugin-bundle-size')
function purify (code, options) { return purifycss(options.content, code, options) }
purify.defaults = { accept: '.css' }
const css = gobble('src/client/styles')
.transform('sass', {
src: 'entry.scss',
dest: `assets/public/bundle-${pkg.version}.css`
})
.transform('postcss', { plugins: [autoprefixer()], map: { inline: false } })
.transform(purify, { content: ['src/client/components/*.js'], info: true, rejected: true })
.transform('postcss', { plugins: [cssnano()], map: { inline: false } })
// add transform for sourceMapUrl to accomodate app basePath
const js = gobble('src/client').transform('rollup', {
sourceMap: true,
plugins: [
nodeResolve({ jsnext: true }),
commonjs({ include: 'node_modules/**', namedExports: { 'preact-redux': ['connect', 'Provider'] } }),
replace({ 'process.env.NODE_ENV': JSON.stringify('production') }),
babel({ babelrc: false, 'presets': ['es2015-minimal-rollup'], 'plugins': [['transform-react-jsx', { 'pragma': 'h' }]] }),
uglify(),
bundleSize()
],
format: 'iife',
entry: 'entry.js',
dest: `assets/public/bundle-${pkg.version}.js`
})
const polyfills = gobble('src/client/utils').include('polyfills.js').moveTo('assets/public')
module.exports = gobble([css, js, polyfills])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment