Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
{
"presets": [
"latest"
]
],
"env": {
"production": {
"presets": [
["latest", {
"es2015": {
"modules": false
}
}]
]
}
}
}
Copy link
Owner Author

@coryhouse coryhouse Feb 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ES2015 modules can be parsed by webpack 2. This enables tree shaking in the production build by disabling Babel's transpilation of ES2015 modules. Since ES2015 modules are statically analyzable, webpack can determine with certainly what code you're not calling, and leave it out of the bundle. This process can reduce your final bundle size. It's commonly called tree shaking or dead code elimination.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've also switched to babel-preset-env since it replaced babel-preset-latest.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to update all "latest" with "env" in .babelrc.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcscott2015 - Correct, and I did that as you can see above.

52 changes: 26 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,42 @@
"author": "Cory House",
"license": "MIT",
"dependencies": {
"whatwg-fetch": "1.0.0"
"whatwg-fetch": "2.0.2"
},
"devDependencies": {
"babel-cli": "6.16.0",
"babel-core": "6.17.0",
"babel-loader": "6.2.5",
"babel-preset-latest": "6.16.0",
"babel-register": "6.16.3",
"babel-cli": "6.23.0",
"babel-core": "6.23.1",
"babel-loader": "6.3.2",
"babel-preset-latest": "6.22.0",
"babel-register": "6.23.0",
"chai": "3.5.0",
"chalk": "1.1.3",
"cheerio": "0.22.0",
"compression": "1.6.2",
"cross-env": "3.1.3",
"css-loader": "0.25.0",
"eslint": "3.8.1",
"eslint-plugin-import": "2.0.1",
"eslint-watch": "2.1.14",
"express": "4.14.0",
"extract-text-webpack-plugin": "1.0.1",
"html-webpack-plugin": "2.22.0",
"jsdom": "9.8.0",
"json-schema-faker": "0.3.6",
"json-server": "0.8.22",
"localtunnel": "1.8.1",
"mocha": "3.1.2",
"nock": "8.1.0",
"npm-run-all": "3.1.1",
"cross-env": "3.1.4",
"css-loader": "0.26.1",
"eslint": "3.15.0",
"eslint-plugin-import": "2.2.0",
"eslint-watch": "3.0.0",
"express": "4.14.1",
"extract-text-webpack-plugin": "2.0.0-beta.4",
"html-webpack-plugin": "2.28.0",
"jsdom": "9.11.0",
"json-schema-faker": "0.4.0",
"json-server": "0.9.5",
"localtunnel": "1.8.2",
"mocha": "3.2.0",
"nock": "9.0.6",
"npm-run-all": "4.0.1",
"nsp": "2.6.2",
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Node security project (NSP) is now built into npm, so you don't need to reference it or call it manually anymore. 😀

"numeral": "1.5.3",
"numeral": "2.0.4",
"open": "0.0.5",
"rimraf": "2.5.4",
"rimraf": "2.6.0",
"style-loader": "0.13.1",
"surge": "0.18.0",
"webpack": "1.13.2",
"webpack-dev-middleware": "1.8.4",
"webpack-hot-middleware": "2.13.0",
"webpack": "2.2.1",
"webpack-dev-middleware": "1.10.1",
"webpack-hot-middleware": "2.17.0",
"webpack-md5-hash": "0.0.5"
}
}
15 changes: 11 additions & 4 deletions webpack.config.dev.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import webpack from 'webpack';
import path from 'path';
import HtmlWebpackPlugin from 'html-webpack-plugin';

export default {
debug: true,
resolve: {
extensions: ['*', '.js', '.jsx', '.json']
},
devtool: 'inline-source-map',
noInfo: false,
entry: [
path.resolve(__dirname, 'src/index')
],
Expand All @@ -15,6 +17,11 @@ export default {
filename: 'bundle.js'
},
plugins: [
new webpack.LoaderOptionsPlugin({
Copy link
Owner Author

@coryhouse coryhouse Feb 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that debug and noInfo are now handled here instead in Webpack 2+.

minimize: false,
debug: true,
noInfo: true // set to false to see a list of every file being bundled.
}),
// Create HTML file that includes reference to bundled JS.
new HtmlWebpackPlugin({
template: 'src/index.html',
Expand All @@ -23,8 +30,8 @@ export default {
],
module: {
loaders: [
{test: /\.js$/, exclude: /node_modules/, loaders: ['babel']},
{test: /\.css$/, loaders: ['style','css']}
{test: /\.js$/, exclude: /node_modules/, loaders: ['babel-loader']},
{test: /\.css$/, loaders: ['style-loader','css-loader']}
]
}
}
19 changes: 12 additions & 7 deletions webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import WebpackMd5Hash from 'webpack-md5-hash';
import ExtractTextPlugin from 'extract-text-webpack-plugin';

export default {
debug: true,
resolve: {
extensions: ['*', '.js', '.jsx', '.json']
},
devtool: 'source-map',
noInfo: false,
entry: {
vendor: path.resolve(__dirname, 'src/vendor'),
main: path.resolve(__dirname, 'src/index')
Expand All @@ -19,6 +20,13 @@ export default {
filename: '[name].[chunkhash].js'
},
plugins: [
// Global loader configuration
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false,
noInfo: true // set to false to see a list of every file being bundled.
}),

// Generate an external css file with a hash in the filename
new ExtractTextPlugin('[name].[contenthash].css'),

Expand Down Expand Up @@ -52,16 +60,13 @@ export default {
trackJSToken: 'INSERT YOUR TOKEN HERE'
}),

// Eliminate duplicate packages when generating bundle
new webpack.optimize.DedupePlugin(),

// Minify JS
new webpack.optimize.UglifyJsPlugin()
],
module: {
loaders: [
{test: /\.js$/, exclude: /node_modules/, loaders: ['babel']},
{test: /\.css$/, loader: ExtractTextPlugin.extract('css?sourceMap')}
{test: /\.js$/, exclude: /node_modules/, loaders: ['babel-loader']},
{test: /\.css$/, loader: ExtractTextPlugin.extract('css-loader?sourceMap')}
]
}
};