Skip to content

Instantly share code, notes, and snippets.

@geoffmiller
geoffmiller / package.json
Created December 10, 2017 14:09
pacakge.json for Webpack 3, dynamic imports, code splitting, and long term caching (with React).
{
"name": "webpack-cs-ltc",
"version": "1.0.0",
"description": "A simple boilerplate for Webpack 3, dynamic imports, code splitting, and long term caching.",
"main": "index.js",
"scripts": {
"start": "webpack --config webpack.config.js",
"dev-server": "webpack-dev-server",
"test": "echo \"Error: no test specified\" && exit 1"
},
@geoffmiller
geoffmiller / .babelrc
Last active December 10, 2017 16:47
.babelrc for Dynamic Imports (react)
{
"presets": [
"react",
["env", {
"targets": {
"browsers": ["last 2 versions"]
}
}],
"stage-0"
],
@geoffmiller
geoffmiller / webpack.config.js
Last active December 11, 2017 17:59
Webpack 3 config for Dynamic Imports, Code Splitting, and Long Term Caching
const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const APP_DIR = path.resolve(__dirname, './src');
const MODULES_DIR = path.resolve(__dirname, './node_modules');
const package = require('./package.json');
module.exports = {
//// MyComponent/MyComponent.js
const MyComponent = ({class, text, setText}) => (
<div
className={class}
onClick={setText}
>{text}</div>
)
export default MyComponent
////
@geoffmiller
geoffmiller / mobx-recompose.jsx
Last active December 11, 2018 22:20
Mobx with Recompose structure
const { compose, mapProps, withHandlers, lifecycle } = Recompose;
const { observable, action } = mobx;
const { inject, observer, Provider } = mobxReact;
const { PropTypes } = React;
// store
// ============================
const counterStore = observable({
// for primitive values, wrap the value inside a observable,
// or wrap it in an plain js object
export default (fn, ...args) => (e) => {
e.preventDefault();
fn(...args);
};