Skip to content

Commit 8607713

Browse files
committed
fix(website): reduce bundle size by excluding inline source maps and add limited support for iOS10 m
1 parent ec0d681 commit 8607713

File tree

2 files changed

+65
-44
lines changed

2 files changed

+65
-44
lines changed

packages/overmind-website/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@
5050
"concurrently": "^3.6.1",
5151
"html-webpack-plugin": "^3.2.0",
5252
"raw-loader": "^0.5.1",
53+
"terser-webpack-plugin": "^1.2.1",
5354
"ts-loader": "^4.4.2",
5455
"tslib": "^1.9.3",
5556
"typescript": "^3.1.3",
5657
"url-loader": "^1.0.1",
5758
"webpack": "^4.15.1",
58-
"webpack-cli": "^3.0.8",
59+
"webpack-cli": "^3.1.2",
5960
"webpack-dev-server": "^3.1.5"
6061
}
6162
}
Lines changed: 63 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,75 @@
11
const HtmlWebpackPlugin = require('html-webpack-plugin')
22
const path = require('path')
33

4-
module.exports = {
5-
devtool: 'inline-source-map',
6-
entry: path.join(__dirname, 'src', 'index.tsx'),
7-
output: {
8-
publicPath: '/',
9-
path: path.join(__dirname, 'dist'),
10-
filename: 'bundle.js',
11-
},
12-
optimization: {
13-
splitChunks: {
14-
chunks: 'all',
4+
module.exports = (env, args) => {
5+
const isProduction = args.mode === 'production'
6+
return {
7+
devtool: isProduction ? 'source-map' : 'inline-source-map',
8+
entry: path.join(__dirname, 'src', 'index.tsx'),
9+
output: {
10+
publicPath: '/',
11+
path: path.join(__dirname, 'dist'),
12+
filename: 'bundle.js',
1513
},
16-
},
17-
devServer: {
18-
proxy: {
19-
'/backend': 'http://localhost:5000',
20-
},
21-
historyApiFallback: true,
22-
},
23-
module: {
24-
rules: [
14+
optimization: Object.assign(
2515
{
26-
test: /\.md/,
27-
use: 'raw-loader',
16+
splitChunks: {
17+
chunks: 'all',
18+
},
2819
},
29-
{
30-
test: /\.(png|woff2)$/,
31-
use: [
32-
{
33-
loader: 'url-loader',
20+
isProduction && {
21+
minimizer: [
22+
(compiler) => {
23+
const TerserPlugin = require('terser-webpack-plugin')
24+
new TerserPlugin({
25+
cache: true,
26+
parallel: true,
27+
sourceMap: true,
28+
terserOptions: {
29+
safari10: true,
30+
},
31+
}).apply(compiler)
3432
},
3533
],
34+
}
35+
),
36+
devServer: {
37+
proxy: {
38+
'/backend': 'http://localhost:5000',
3639
},
37-
{
38-
test: /\.tsx?$/,
39-
loader: 'ts-loader',
40-
include: path.join(__dirname, 'src'),
41-
options: {
42-
allowTsInNodeModules: true,
40+
historyApiFallback: true,
41+
},
42+
module: {
43+
rules: [
44+
{
45+
test: /\.md/,
46+
use: 'raw-loader',
4347
},
44-
},
48+
{
49+
test: /\.(png|woff2)$/,
50+
use: [
51+
{
52+
loader: 'url-loader',
53+
},
54+
],
55+
},
56+
{
57+
test: /\.tsx?$/,
58+
loader: 'ts-loader',
59+
include: path.join(__dirname, 'src'),
60+
options: {
61+
allowTsInNodeModules: true,
62+
},
63+
},
64+
],
65+
},
66+
resolve: {
67+
extensions: ['.tsx', '.ts', '.js'],
68+
},
69+
plugins: [
70+
new HtmlWebpackPlugin({
71+
template: path.join(__dirname, 'backend', 'index.html'),
72+
}),
4573
],
46-
},
47-
resolve: {
48-
extensions: ['.tsx', '.ts', '.js'],
49-
},
50-
plugins: [
51-
new HtmlWebpackPlugin({
52-
template: path.join(__dirname, 'backend', 'index.html'),
53-
}),
54-
],
74+
}
5575
}

0 commit comments

Comments
 (0)