From 0b412dac6d631f98fff93a3728267aac30a8f621 Mon Sep 17 00:00:00 2001 From: Mael Thomas Date: Mon, 27 Mar 2017 13:42:10 +0200 Subject: [PATCH] =?UTF-8?q?:bug:=20R=C3=A9solution=20du=20bug=20de=20la=20?= =?UTF-8?q?compilation=20minifi=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/.babelrc | 3 ++- source/webpack.config.js | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) 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: