optimized bundle size and dependencies

This commit is contained in:
Jori Lallo
2016-05-03 00:32:40 -07:00
parent 2b849b12c9
commit 5e5f37b3c0
6 changed files with 12 additions and 22 deletions

View File

@ -5,7 +5,8 @@
"main": "index.js",
"scripts": {
"clean": "rimraf dist",
"build:webpack": "cross-env NODE_ENV=production webpack --config webpack.config.prod.js --progress --colors",
"build:webpack": "cross-env NODE_ENV=production webpack --config webpack.config.prod.js --progress",
"build:analyze": "cross-env NODE_ENV=production webpack --config webpack.config.prod.js --json | webpack-bundle-size-analyzer",
"build": "npm run clean && npm run build:webpack",
"start": "cross-env NODE_ENV=development DEBUG=1 ./node_modules/.bin/nodemon --watch server index.js",
"lint": "eslint src"
@ -43,7 +44,6 @@
"koa-mount": "^2.0.0",
"koa-router": "^7.0.1",
"koa-sendfile": "^2.0.0",
"koa-webpack-dev-middleware": "^1.2.0",
"localenv": "^0.2.2",
"pg": "^4.5.3",
"pg-hstore": "^2.3.2",
@ -75,7 +75,6 @@
"koa-convert": "^1.2.0",
"koa-webpack-dev-middleware": "^1.2.0",
"koa-webpack-hot-middleware": "^1.0.3",
"localforage": "^1.4.0",
"lodash": "^4.3.0",
"marked": "^0.3.5",
"node-dev": "^3.1.0",
@ -92,15 +91,12 @@
"redux": "^3.3.1",
"redux-logger": "^2.6.1",
"redux-persist": "^3.0.1",
"redux-storage": "^4.0.0",
"redux-storage-engine-localstorage": "^1.0.0",
"redux-thunk": "^2.0.1",
"sass-loader": "^3.2.0",
"style-loader": "^0.13.0",
"sw-toolbox": "^3.1.1",
"to-markdown": "^2.0.1",
"url-loader": "^0.5.7",
"webpack": "^1.12.12",
"webpack-koa-hot-middleware": "^0.1.2"
"webpack": "^1.12.12"
}
}

View File

@ -1,4 +1,5 @@
import _ from 'lodash';
import _xor from 'lodash/xor';
import _last from 'lodash/last';
import { combineReducers } from 'redux';
import {
@ -14,11 +15,11 @@ const activeEditors = (state = [ActiveEditors.MARKDOWN, ActiveEditors.TEXT], act
switch (action.type) {
case TOGGLE_EDITORS: {
// TODO: A rewrite would be nice
const newState = _.xor(state, [action.toggledEditor]);
const newState = _xor(state, [action.toggledEditor]);
if (newState.length > 0) {
return newState;
} else {
return _.xor([ActiveEditors.MARKDOWN, ActiveEditors.TEXT], [action.toggledEditor]);
return _xor([ActiveEditors.MARKDOWN, ActiveEditors.TEXT], [action.toggledEditor]);
}
}
default:
@ -56,7 +57,7 @@ const textDefaultState = {
};
const text = (state = textDefaultState, action) => {
const lastRevision = _.last(state.revisions);
const lastRevision = _last(state.revisions);
switch (action.type) {
case UPDATE_TEXT: {

View File

@ -1,4 +1,4 @@
import _ from 'lodash';
import _map from 'lodash/map';
import auth from './auth';
import constants from '../constants';
@ -84,7 +84,7 @@ class ApiClient {
// Helpers
constructQueryString = (data) => {
return _.map(data, (v, k) => {
return _map(data, (v, k) => {
return `${encodeURIComponent(k)}=${encodeURIComponent(v)}`;
}).join('&');
};

View File

@ -6,8 +6,6 @@ import { createStore, applyMiddleware } from 'redux';
import { routerMiddleware } from 'react-router-redux';
import { persistStore, autoRehydrate } from 'redux-persist';
import thunkMiddleware from 'redux-thunk';
import * as storage from 'redux-storage';
import createEngine from 'redux-storage-engine-localstorage';
import createLogger from 'redux-logger';
import History from 'utils/History';
@ -18,19 +16,16 @@ import reducers from 'reducers';
import 'utils/base-styles.scss';
import Home from 'scenes/Home';
import App from 'scenes/App';
// import App from 'scenes/App';
import Dashboard from 'scenes/Dashboard';
import SlackAuth from 'scenes/SlackAuth';
// Redux
const reducer = storage.reducer(reducers);
const loggerMiddleware = createLogger();
const routerMiddlewareWithHistory = routerMiddleware(History);
const createStoreWithMiddleware = (createStore);
const store = createStore(reducer, applyMiddleware(
const store = createStore(reducers, applyMiddleware(
thunkMiddleware,
routerMiddlewareWithHistory,
loggerMiddleware,

View File

@ -7,7 +7,6 @@ const developmentWebpackConfig = Object.assign(commonWebpackConfig, {
cache: true,
devtool: 'eval',
entry: [
'babel-polyfill',
'webpack-hot-middleware/client',
'./src/index',
],

View File

@ -7,7 +7,6 @@ productionWebpackConfig = Object.assign(commonWebpackConfig, {
cache: true,
devtool: 'cheap-module-source-map',
entry: [
'babel-polyfill',
'./src/index',
],
output: {