forked from external-repos/squoosh
Only use Babel to process .js files.
This commit is contained in:
6
.babelrc
6
.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 @@
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
@@ -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',
|
||||
@@ -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 })
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user