Skip to content

Commit

Permalink
feature: Include polyfill.io for web builds
Browse files Browse the repository at this point in the history
Provide a custom `HtmlWebpackPlugin` option to only bundle the script for
polyfill.io for the web/mWeb platform - it's not needed for desktop as
it already works with latest tech

The `ResizeObserver` is added as it's not included in the `default` features
It's needed for the app to work on iOS 12 mWeb Safari

The `gated` flag is added to skip polyfilling a feature that is already supported
natively by the browser
  • Loading branch information
kidroca committed May 6, 2021
1 parent 7a7fd7d commit 1494e3f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/webpack/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const webpackConfig = {
new HtmlWebpackPlugin({
template: 'web/index.html',
filename: 'index.html',
usePolyfillIO: platform === 'web',
}),

// Copies favicons into the dist/ folder to use for unread status
Expand Down
4 changes: 4 additions & 0 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
</style>
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1">
<link rel="shortcut icon" id="favicon" href="/favicon.png">
<% if (htmlWebpackPlugin.options.usePolyfillIO) { %>
<!-- polyfill.io is only needed on Web to support older browsers. It should not be loaded for desktop -->
<script src="https://polyfill.io/v3/polyfill.min.js?features=default%2CResizeObserver&flags=gated"></script>
<% } %>
</head>
<body>
<div style="position: absolute; top: 0; left: 0; right: 0; height: 30px;" id="drag-area"></div>
Expand Down

0 comments on commit 1494e3f

Please sign in to comment.