Skip to content

Instantly share code, notes, and snippets.

Avatar

Gaurav Tiwari gauravtiwari

View GitHub Profile
View webpack_03.js
/*
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;
View config.js
// Initialize config object
var config = {};
module.exports = config;
View entry.js
// Entry module/file for webpack
var config = require('./config.js');
config.entry = '../main.js';
View output.js
var config = require('./config.js');
// Main output directory and file for bundled js
config.output = {
path: './dist',
filename: 'bundle.js'
};
View plugins.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 */ })
];
View externals.js
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']
})];
View general.js
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 Aug 13, 2016
A dynamic react relay component renderer
View renderer.js
/*
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 Oct 2, 2016
Initialise graphql client
View graphql_client.rb
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 Oct 2, 2016
A list of queries declared in ruby to execute against given graphql server
View graphql_client_queries.rb
IndexQuery = API::Client.parse <<-'GRAPHQL'
query {
root {
id,
tags,
posts(first: 10) {
edges {
node {
id,
title,
You can’t perform that action at this time.