diff --git a/source/.babelrc b/source/.babelrc index a90201ae4..8353486b5 100644 --- a/source/.babelrc +++ b/source/.babelrc @@ -3,7 +3,8 @@ ["env", { "targets": { "browsers": ["last 2 versions", "safari >= 7"] - } + }, + "modules": false }], "react" ], diff --git a/source/webpack.config.js b/source/webpack.config.js index 9082d7c7b..39c02b6e3 100644 --- a/source/webpack.config.js +++ b/source/webpack.config.js @@ -1,9 +1,13 @@ var webpack = require('webpack'), - autoprefixer = require('autoprefixer') + autoprefixer = require('autoprefixer'), + prodEnv = process.env.NODE_ENV == 'production' // eslint-disable-line no-undef module.exports = { devtool: 'cheap-module-source-map', - entry: [ + entry: prodEnv ? [ + 'babel-polyfill', + './source/entry.js' + ] : [ 'webpack-dev-server/client?http://localhost:3000/', 'webpack/hot/only-dev-server', 'react-hot-loader/patch', @@ -54,10 +58,17 @@ module.exports = { loader: 'url-loader?limit=10000!img-loader?progressive=true' }, { test: /\.ne$/, - loader: 'nearley-loader' + loader: 'babel-loader!nearley-loader' }] }, - plugins: [ + plugins: prodEnv ? [ + new webpack.NoEmitOnErrorsPlugin(), + // in order to use the fetch polyfill: + new webpack.ProvidePlugin({ + 'fetch': 'imports?this=>global!exports?global.fetch!whatwg-fetch' + }), + new webpack.optimize.UglifyJsPlugin() + ] : [ new webpack.HotModuleReplacementPlugin(), new webpack.NoEmitOnErrorsPlugin(), // in order to use the fetch polyfill: