diff --git a/.babelrc b/.babelrc index ca3dcca..dfd0dd4 100644 --- a/.babelrc +++ b/.babelrc @@ -1,5 +1,16 @@ { - "presets" : [ - "latest" - ] -} + "presets": [ + "env" + ], + "env": { + "production": { + "presets": [ + ["env", { + "es2015": { + "modules": false + } + }] + ] + } + } +} \ No newline at end of file diff --git a/package.json b/package.json index 1f3ad5b..961242e 100644 --- a/package.json +++ b/package.json @@ -25,42 +25,42 @@ "author": "Cory House", "license": "MIT", "dependencies": { - "whatwg-fetch": "1.0.0" + "whatwg-fetch": "2.0.3" }, "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", - "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", - "nsp": "2.6.2", - "numeral": "1.5.3", + "babel-cli": "6.26.0", + "babel-core": "6.26.0", + "babel-loader": "7.1.2", + "babel-preset-env": "1.6.0", + "babel-register": "6.26.0", + "chai": "4.1.2", + "chalk": "2.1.0", + "cheerio": "1.0.0-rc.2", + "compression": "1.7.1", + "cross-env": "5.0.5", + "css-loader": "0.28.7", + "eslint": "4.8.0", + "eslint-plugin-import": "2.7.0", + "eslint-watch": "3.1.2", + "express": "4.16.2", + "extract-text-webpack-plugin": "3.0.1", + "html-webpack-plugin": "2.30.1", + "jsdom": "9.11.0", + "json-schema-faker": "0.4.0", + "json-server": "0.12.0", + "localtunnel": "1.8.3", + "mocha": "4.0.1", + "nock": "9.0.22", + "npm-run-all": "4.1.1", + "nsp": "2.8.1", + "numeral": "2.0.6", "open": "0.0.5", - "rimraf": "2.5.4", - "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", + "rimraf": "2.6.2", + "style-loader": "0.19.0", + "surge": "0.19.0", + "webpack": "3.6.0", + "webpack-dev-middleware": "1.12.0", + "webpack-hot-middleware": "2.19.1", "webpack-md5-hash": "0.0.5" } } diff --git a/src/api/baseUrl.js b/src/api/baseUrl.js index 0a0cf07..da08901 100644 --- a/src/api/baseUrl.js +++ b/src/api/baseUrl.js @@ -4,7 +4,7 @@ export default function getBaseUrl() { function getQueryStringParameterByName(name, url) { if(!url) url = window.location.href; - name = name.replace(/[\[\]]/g, "\\$&"); + name = name.replace(/[[]]/g, "\\$&"); var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex.exec(url); if(!results) return null; diff --git a/webpack.config.dev.js b/webpack.config.dev.js index 1eadaf2..3a5d61a 100644 --- a/webpack.config.dev.js +++ b/webpack.config.dev.js @@ -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') ], @@ -15,16 +17,21 @@ export default { filename: 'bundle.js' }, plugins: [ + new webpack.LoaderOptionsPlugin({ + 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({ + new HtmlWebpackPlugin({ template: 'src/index.html', inject: true }) ], module: { - loaders: [ - {test: /\.js$/, exclude: /node_modules/, loaders: ['babel']}, - {test: /\.css$/, loaders: ['style','css']} + rules: [ + {test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader'}, + {test: /\.css$/, use: ['style-loader','css-loader']} ] } -} +} \ No newline at end of file diff --git a/webpack.config.prod.js b/webpack.config.prod.js index af3f518..07a38a7 100644 --- a/webpack.config.prod.js +++ b/webpack.config.prod.js @@ -1,13 +1,14 @@ -import path from 'path'; import webpack from 'webpack'; +import path from 'path'; import HtmlWebpackPlugin from 'html-webpack-plugin'; 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') @@ -19,17 +20,27 @@ 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'), + // Hash the files using MD5 so that their names change when the content changes. new WebpackMd5Hash(), + // Use CommonsChunkPlugin to create a separate bundle // of vendor libraries so that they're cached separately. new webpack.optimize.CommonsChunkPlugin({ name: 'vendor' }), + // Create HTML file that includes reference to bundled JS. - new HtmlWebpackPlugin({ + new HtmlWebpackPlugin({ template: 'src/index.html', minify: { removeComments: true, @@ -48,15 +59,14 @@ export default { // using htmlWebpackPlugin.options.varName trackJSToken: 'a04ce9b4a6f54171a996364ca786c5c8' }), - // 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')} + rules: [ + {test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader'}, + {test: /\.css$/, loader: ExtractTextPlugin.extract('css-loader?sourceMap')} ] } -} +}; \ No newline at end of file