Created
September 12, 2016 15:15
-
-
Save ezekielchentnik/4db815ddab1f40224d6334383a72a568 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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