Skip to content

Commit 4fc3f11

Browse files
author
Steven Truesdell
committed
chore: update readme. add custom babel preset
1 parent 712a16f commit 4fc3f11

File tree

7 files changed

+46
-51
lines changed

7 files changed

+46
-51
lines changed

.babelrc

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,25 @@
11
{
22
"env": {
3-
"server": {
4-
"presets": ["latest", "react"],
5-
"plugins": ["transform-decorators-legacy",
6-
"transform-class-properties",
7-
"transform-object-rest-spread",
8-
"transform-regenerator", ["transform-runtime", {
9-
"helpers": false,
10-
"polyfill": false,
11-
"regenerator": true
12-
}],
3+
"development": {
4+
"presets": ["boldr"],
5+
"plugins": [
136
["module-resolver", {
147
"root": ["./src"]
158
}]
169
]
1710
},
18-
"client": {
19-
"presets": ["latest", "react"],
11+
"production": {
12+
"presets": ["boldr"],
2013
"plugins": [
21-
"transform-decorators-legacy",
22-
"transform-class-properties",
23-
"transform-object-rest-spread",
24-
"transform-react-constant-elements",
25-
"transform-react-inline-elements",
2614
"lodash",
27-
["transform-runtime", {
28-
"helpers": false,
29-
"polyfill": false,
30-
"regenerator": true
31-
}],
3215
["module-resolver", {
3316
"root": ["./src"]
3417
}]
3518
]
3619
},
3720
"test": {
38-
"presets": ["latest", "react"],
39-
"plugins": ["istanbul", "transform-decorators-legacy",
40-
"transform-class-properties",
41-
"transform-object-rest-spread",
42-
"transform-regenerator", ["transform-runtime", {
43-
"helpers": false,
44-
"polyfill": false,
45-
"regenerator": true
46-
}],
47-
["module-resolver", {
21+
"presets": ["boldr"],
22+
"plugins": ["istanbul", ["module-resolver", {
4823
"root": ["./src"]
4924
}]
5025
]

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,24 @@ Running the two commands below will compile your application and serve the produ
3636
#### Using DLLs
3737
Taking advantage of Webpack's DLLs is pretty easy in this project. The command is `npm run build:dlls`. It creates a `vendor.json` tfile in the webpack directory and places the DLL bundle in `static/assets/dlls`. When you add new dependencies to your project, all you need to do is add the name to the on-going list within `webpack/dll.config.js`. As a side note, rather than using DLLs in production (which you shouldnt, by the way), you'll want to add the package into the list of vendor dependencies inside `webpack/webpack.config.client.js`.
3838

39-
If you don't feel like using DLLs, set WEBPACK_DLLS to 0 in the `package.json`
39+
If you don't feel like using DLLs, set WEBPACK_DLLS to 0 in the `package.json`
40+
41+
#### Where are the Babel transforms?
42+
Inspired by Create React App, a custom Babel preset was created containing some common Babel plugins and presets. **Why?** Typically I find myself using the exact same Babel plugins, and rather than installing 5+ different packages, a single command takes care of it.
43+
44+
**babel-preset-boldr contains:**
45+
- `babel-plugin-transform-class-properties`
46+
- `babel-plugin-transform-decorators-legacy`
47+
- `babel-plugin-transform-function-bind`
48+
- `babel-plugin-transform-object-rest-spread`
49+
- `babel-plugin-transform-react-constant-elements`
50+
- `babel-plugin-transform-react-jsx-self`
51+
- `babel-plugin-transform-react-jsx-source`
52+
- `babel-plugin-transform-regenerator`
53+
- `babel-plugin-transform-runtime`
54+
- `babel-preset-latest`
55+
- `babel-preset-react`
56+
- `babel-runtime`
4057

4158
## Resources
4259
- [`React Redux Links`](https://github.com/markerikson/react-redux-links)

package.json

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
"env": {
99
"DEBUG": "boldr:*",
1010
"NODE_ENV": "production",
11-
"BABEL_ENV": "client",
11+
"BABEL_ENV": "production",
1212
"SSR_PORT": 3000
1313
}
1414
},
1515
"build:server": {
1616
"command": "./node_modules/.bin/webpack --config tools/webpack/webpack.config.node.js",
1717
"env": {
1818
"NODE_ENV": "production",
19-
"BABEL_ENV": "server",
19+
"BABEL_ENV": "production",
2020
"SSR_PORT": 3000
2121
}
2222
},
@@ -25,7 +25,7 @@
2525
"env": {
2626
"DEBUG": "boldr:*",
2727
"NODE_ENV": "development",
28-
"BABEL_ENV": "client",
28+
"BABEL_ENV": "development",
2929
"SSR_PORT": 3000,
3030
"HMR_PORT": 3001,
3131
"WEBPACK_DLLS": 1
@@ -36,7 +36,7 @@
3636
"env": {
3737
"DEBUG": "boldr:*",
3838
"NODE_ENV": "development",
39-
"BABEL_ENV": "client",
39+
"BABEL_ENV": "development",
4040
"SSR_PORT": 3000,
4141
"HMR_PORT": 3001,
4242
"WEBPACK_DLLS": 1
@@ -59,7 +59,7 @@
5959
}
6060
},
6161
"scripts": {
62-
"build": "npm-run-all -s build:server build:client",
62+
"build": "npm-run-all -s clean build:server build:client",
6363
"build:client": "better-npm-run build:client",
6464
"build:server": "better-npm-run build:server",
6565
"build:dlls": "webpack --verbose --colors --display-error-details --config ./tools/webpack/dll.config.js",
@@ -126,21 +126,15 @@
126126
"instrument": false
127127
},
128128
"devDependencies": {
129+
"assets-webpack-plugin": "^3.4.0",
129130
"autoprefixer": "^6.4.1",
130131
"babel-core": "^6.14.0",
131132
"babel-loader": "^6.2.5",
132133
"babel-plugin-istanbul": "^2.0.1",
133134
"babel-plugin-lodash": "^3.2.9",
134135
"babel-plugin-module-resolver": "^2.2.0",
135-
"babel-plugin-transform-class-properties": "^6.11.5",
136-
"babel-plugin-transform-decorators-legacy": "^1.3.4",
137-
"babel-plugin-transform-object-rest-spread": "^6.8.0",
138-
"babel-plugin-transform-react-constant-elements": "^6.9.1",
139-
"babel-plugin-transform-react-inline-elements": "^6.8.0",
140-
"babel-plugin-transform-runtime": "^6.15.0",
141136
"babel-polyfill": "^6.13.0",
142-
"babel-preset-latest": "^6.14.0",
143-
"babel-preset-react": "^6.11.1",
137+
"babel-preset-boldr": "^1.0.1",
144138
"babel-register": "^6.14.0",
145139
"chai": "^3.5.0",
146140
"chai-enzyme": "^0.5.1",
@@ -174,7 +168,7 @@
174168
"sinon-chai": "^2.8.0",
175169
"style-loader": "^0.13.1",
176170
"url-loader": "^0.5.7",
177-
"webpack": "^2.1.0-beta.24",
171+
"webpack": "^2.1.0-beta.25",
178172
"webpack-dev-middleware": "^1.8.2",
179173
"webpack-hot-middleware": "^2.12.2",
180174
"webpack-node-externals": "^1.4.3"
@@ -185,7 +179,7 @@
185179
"compression": "^1.6.2",
186180
"debug": "^2.2.0",
187181
"express": "^4.14.0",
188-
"lodash": "^4.16.1",
182+
"lodash": "^4.16.2",
189183
"npm-run-all": "^3.1.0",
190184
"react": "^15.3.2",
191185
"react-dom": "^15.3.2",

src/scenes/Home/actions.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import request from 'superagent';
2-
import { processResponse } from 'core/api/helpers';
32

43
export const FETCH_POSTS_REQUEST = 'FETCH_POSTS_REQUEST';
54
export const FETCH_POSTS_SUCCESS = 'FETCH_POSTS_SUCCESS';

tools/webpack/dev.server.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const Express = require('express');
22
const webpack = require('webpack');
33
const webpackDevMiddleware = require('webpack-dev-middleware');
44
const webpackHotMiddleware = require('webpack-hot-middleware');
5+
56
const debug = require('debug')('boldr:webpack-ds');
67
const config = require('../defaults');
78
const wpConfig = require('./index.js');
@@ -26,6 +27,7 @@ const app = new Express();
2627
app.use(webpackDevMiddleware(compiler, serverOptions));
2728
app.use(webpackHotMiddleware(compiler));
2829

30+
2931
/* eslint-disable */
3032
app.listen(config.HMR_PORT, function onAppListening(err) {
3133
if (err) {

tools/webpack/util/isomorphic.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const path = require('path');
22
const WebpackIsomorphicToolsPlugin = require('webpack-isomorphic-tools/plugin');
33

44
module.exports = {
5-
debug: true,
5+
debug: false,
66
patch_require: true,
77
webpack_assets_file_path: path.join(__dirname, '..', '..', '..', 'static', 'webpack-assets.json'),
88
webpack_stats_file_path: path.join(__dirname, '..', '..', '..', 'static', 'webpack-stats.json'),

tools/webpack/webpack.config.client.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const webpack = require('webpack');
44
const WebpackIsomorphicToolsPlugin = require('webpack-isomorphic-tools/plugin');
55
const HappyPack = require('happypack');
66
const autoprefixer = require('autoprefixer');
7+
const AssetsPlugin = require('assets-webpack-plugin');
78
const ExtractTextPlugin = require('extract-text-webpack-plugin');
89
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
910

@@ -203,7 +204,14 @@ module.exports = function webpackConfig() {
203204
// A plugin for a more aggressive chunk merging strategy. Even similar chunks
204205
// are merged if the total size is reduced enough.
205206
// http://webpack.github.io/docs/list-of-plugins.html#aggressivemergingplugin
206-
ifProd(new webpack.optimize.AggressiveMergingPlugin())
207+
ifProd(new webpack.optimize.AggressiveMergingPlugin()),
208+
209+
new AssetsPlugin({
210+
path: path.resolve(config.ASSETS_DIR),
211+
filename: 'assets.js',
212+
processOutput: x => `module.exports = ${JSON.stringify(x)};`
213+
}),
214+
// ifDev(new DashboardPlugin({ port: 3001 }))
207215
]),
208216
/*
209217
* Include polyfills and/or mocks for node

0 commit comments

Comments
 (0)