Skip to content

Instantly share code, notes, and snippets.

View ezekielchentnik's full-sized avatar

Ezekiel Chentnik ezekielchentnik

View GitHub Profile
require('babel-register');
module.exports = require('./webpack.client');
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");
'use strict';
const version = 'v0.01::';
const staticCacheName = version + 'static';
function updateStaticCache() {
return caches.open(staticCacheName)
.then( cache => {
// These items won't block the installation of the Service Worker
cache.addAll([
import webpack from 'webpack';
export default function(name, doneMessage){
return new webpack.ProgressPlugin(function(percentage, message) {
var MOVE_LEFT = new Buffer('1b5b3130303044', 'hex').toString();
var CLEAR_LINE = new Buffer('1b5b304b', 'hex').toString();
process.stdout.write(CLEAR_LINE + 'webpack compiling ['+name+']: ' + Math.round(percentage * 100) + '%: ' + message + MOVE_LEFT);
if(percentage == 1){
process.stdout.write(doneMessage || "webpack say good, fire up...\n");
@ezekielchentnik
ezekielchentnik / devServer.js
Last active August 2, 2016 21:51
webpack dev config with dev server, for react, latest greatest hot module reloading. Also uses postcss to compile our css (sass compatible), and image optimization
var WebpackDevMiddleware = require('webpack-dev-middleware');
var WebpackHotMiddleware = require('webpack-hot-middleware');
var historyApiFallback = require('connect-history-api-fallback');
var express = require('express');
var webpack = require('webpack');
var config = require('./webpack.config.dev');
var app = express();
var compiler = webpack(config);
@ezekielchentnik
ezekielchentnik / ApiActions.js
Created August 12, 2016 16:38
Session Storage interval caching with fetch and redux
const OPTIONS = {
credentials: 'include',
headers: {
'Accept': 'application/json', // eslint-disable-line
'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest'
}
};
export function parseResponse(response) {
@ezekielchentnik
ezekielchentnik / isBrowser.js
Created September 2, 2016 15:53
Simple helper to facilitate checking for browser when doing SSR
export default typeof window !== 'undefined'
export default (process.env.NODE_ENV && process.env.NODE_ENV === 'development')
import IS_DEV from '../src/server/utils/isDev';
const hash = IS_DEV ? '[name]' : '[name]-[chunkhash]';
new webpack.DefinePlugin({
'IS_BROWSER': true,
'IS_DEV': IS_DEV,
'process.env.NODE_ENV': JSON.stringify(IS_DEV ? 'development' : 'production')
}),
output: {
path: path.join(root, '/build/assets'),
publicPath,
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')