Skip to content

Instantly share code, notes, and snippets.

const rewire = require('rewire');
const defaults = rewire('react-scripts/scripts/start.js');
const configFactory = defaults.__get__('configFactory');
const devConfigFactory = configFactory('development');
// Do stuff
// i.e. devConfigFactory.module.rules.xxxxxx
const patchedDevConfigFactory = function() {
return devConfigFactory;
@timothyallan
timothyallan / model_file.php
Created November 1, 2016 03:35
Rearrange ouput JSON to eliminate a Laravel 5.x "Pivot" table and just return the single value. Can be used for all sorts of remapping.
public function toArray()
{
$attributes = $this->attributesToArray();
$attributes = array_merge($attributes, $this->relationsToArray());
// Detect if there is a pivot value and return that as the default value
if (isset($attributes['pivot']['value'])) {
$attributes['value'] = $attributes['pivot']['value'];
unset($attributes['pivot']);
}