Skip to content

Instantly share code, notes, and snippets.

/*
Split webpack config into multiple files
*/
var requireDir = require('require-dir');
// Require the webpack.config directory
var configs = requireDir('./webpack.configs');
// Lets export the config
module.exports = configs.config;
// Initialize config object
var config = {};
module.exports = config;
// Entry module/file for webpack
var config = require('./config.js');
config.entry = '../main.js';
var config = require('./config.js');
// Main output directory and file for bundled js
config.output = {
path: './dist',
filename: 'bundle.js'
};
// Initialize plugins for webpack
var config = require('./config.js');
var webpack = require('webpack');
// Define empty plugins array
config.plugins = [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({ /* can pass many options */ })
];
var config = require('./config.js');
var nodeExternals = require('webpack-node-externals');
// Ignore node_modules/* so all modules won't get bundled and include
// only whitelisted modules in bundle
config.externals = [nodeExternals({
whitelist: ['require', 'webpack', 'jquery']
})];
var config = require('./config.js');
// SourceMap generation
config.devtool = 'inline-source-map';
// Directory context
config.context = __dirname;
// Target environment
config.target = 'node';
@gauravtiwari
gauravtiwari / renderer.js
Created August 13, 2016 15:31
A dynamic react relay component renderer
/*
Mount and Unmount react components at nodes
*/
/* global Turbolinks, ReactHelper */
import ReactDOM from 'react-dom';
import Relay from 'react-relay';
import React from 'react';
@gauravtiwari
gauravtiwari / graphql_client.rb
Created October 2, 2016 10:21
Initialise graphql client
module API
HTTPAdapter = GraphQL::Client::HTTP.new(ENV['API_URL'])
#
# Pass block to send auth token
# def headers(context)
# {
# "Authorization" => "Bearer #{ENV['ACCESS_TOKEN']}"
# }
# end
@gauravtiwari
gauravtiwari / graphql_client_queries.rb
Created October 2, 2016 10:23
A list of queries declared in ruby to execute against given graphql server
IndexQuery = API::Client.parse <<-'GRAPHQL'
query {
root {
id,
tags,
posts(first: 10) {
edges {
node {
id,
title,