Skip to content

Commit

Permalink
Merge pull request GoogleChromeLabs#17 from GoogleChromeLabs/babel-fixes
Browse files Browse the repository at this point in the history
Only use Babel to process .js files.
  • Loading branch information
developit authored Apr 17, 2018
2 parents 02081c3 + 718443d commit 448babc
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 21 deletions.
6 changes: 2 additions & 4 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"env",
{
"loose": true,
"uglify": true,
"uglify": false,
"modules": false,
"targets": {
"browsers": "last 2 versions"
Expand All @@ -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",
[
Expand All @@ -30,4 +28,4 @@
}
]
]
}
}
51 changes: 34 additions & 17 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const fs = require('fs');
const path = require('path');
const webpack = require('webpack');
const CleanWebpackPlugin = 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 HtmlWebpackPlugin = require('html-webpack-plugin');
Expand Down Expand Up @@ -49,23 +50,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',
Expand Down Expand Up @@ -113,6 +97,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 })
}
]
},
Expand Down Expand Up @@ -225,6 +220,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)
Expand Down

0 comments on commit 448babc

Please sign in to comment.