diff --git a/.babelrc b/.babelrc index a9d2d2e6..453d1afc 100644 --- a/.babelrc +++ b/.babelrc @@ -4,7 +4,7 @@ "env", { "loose": true, - "uglify": true, + "uglify": false, "modules": false, "targets": { "browsers": "last 2 versions" @@ -17,10 +17,8 @@ ] ], "plugins": [ - "syntax-dynamic-import", "transform-decorators-legacy", "transform-class-properties", - "transform-object-rest-spread", "transform-react-constant-elements", "transform-react-remove-prop-types", [ @@ -30,4 +28,4 @@ } ] ] -} \ No newline at end of file +} diff --git a/webpack.config.js b/webpack.config.js index 1b5c41fb..a243d3bb 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,6 +2,7 @@ const fs = require('fs'); const path = require('path'); const webpack = require('webpack'); const CleanPlugin = require('clean-webpack-plugin'); +const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); const ProgressBarPlugin = require('progress-bar-webpack-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin'); @@ -52,23 +53,6 @@ module.exports = function (_, env) { }, module: { rules: [ - { - test: /\.tsx?$/, - exclude: nodeModules, - // Ensure typescript is compiled prior to Babel running: - enforce: 'pre', - use: [ - // pluck the sourcemap back out so Babel creates a composed one: - 'source-map-loader', - 'ts-loader' - ] - }, - { - test: /\.(ts|js)x?$/, - loader: 'babel-loader', - // Don't respect any Babel RC files found on the filesystem: - options: Object.assign(readJson('.babelrc'), { babelrc: false }) - }, { test: /\.(scss|sass)$/, loader: 'sass-loader', @@ -116,6 +100,17 @@ module.exports = function (_, env) { } } ] + }, + { + test: /\.tsx?$/, + exclude: nodeModules, + loader: 'ts-loader' + }, + { + test: /\.jsx?$/, + loader: 'babel-loader', + // Don't respect any Babel RC files found on the filesystem: + options: Object.assign(readJson('.babelrc'), { babelrc: false }) } ] }, @@ -253,6 +248,28 @@ module.exports = function (_, env) { }) ].filter(Boolean), // Filter out any falsey plugin array entries. + optimization: { + minimizer: [ + new UglifyJsPlugin({ + sourceMap: isProd, + extractComments: { + file: 'build/licenses.txt' + }, + uglifyOptions: { + compress: { + inline: 1 + }, + mangle: { + safari10: true + }, + output: { + safari10: true + } + } + }) + ] + }, + // Turn off various NodeJS environment polyfills Webpack adds to bundles. // They're supposed to be added only when used, but the heuristic is loose // (eg: existence of a variable called setImmedaite in any scope)