lbry-desktop/web/webpack.sw.config.js
Dan Peterson 03f69eff86
Browser push notifications (#133)
* fix type error

fix is subscribed check

- Persist subscription data locally
- add / remove subscription during log in / out
- Use store directly in hook

Add toast error if subscription fails

Revert removal of v2

hotfix linting issue

Add custom notification handler

- fix isSupported flag
- make icon color compatible with light/dark theme
- fix icon on notifications blocked banner

wip: add push notification banner to notifications page.

- ignore failed deletions via internal API
- add ua parsing package
- add more robust meta data to token save

refactor naming + add push toggle to notification button

shift some code around

update css naming o proper BEM notation

update notifications UI

remove now unneeded util function

Update push notification system to sue firebase sdk

separate service worker webpack bundling

update service worker to use firebase sdk

Add firebase config

Add firebase and remove filemanager

Stub out the basics for browser push notifications.

* fix safari

* try smaller image for badge

* add token validation with server, refactor code

* remove param

* add special icon for web notification badge

* add translations

* add missing trans for toast error

* add pushRequest method that will not prompt users who have subscribed but since disabled notifications in the settings.
2021-10-27 10:38:10 -04:00

41 lines
1.3 KiB
JavaScript

const NODE_ENV = process.env.NODE_ENV || 'development';
const path = require('path');
const WriteFilePlugin = require('write-file-webpack-plugin');
const Dotenv = require('dotenv-webpack');
const { getIfUtils } = require('webpack-config-utils');
const { ifProduction } = getIfUtils(NODE_ENV);
const DIST_ROOT = path.resolve(__dirname, 'dist/');
const WEB_PLATFORM_ROOT = __dirname;
module.exports = {
target: 'web',
mode: ifProduction('production', 'development'),
devtool: ifProduction('source-map', 'eval-cheap-module-source-map'),
entry: path.join(WEB_PLATFORM_ROOT, '/src/service-worker.js'),
output: {
filename: 'sw.js',
path: DIST_ROOT,
globalObject: 'this',
},
plugins: [
new WriteFilePlugin(),
new Dotenv({
allowEmptyValues: true, // allow empty variables (e.g. `FOO=`) (treat it as empty string, rather than missing)
systemvars: true, // load all the predefined 'process.env' variables which will trump anything local per dotenv specs.
silent: false, // hide any errors
defaults: true, // load '.env.defaults' as the default values if empty.
}),
],
resolve: {
alias: {
$web: WEB_PLATFORM_ROOT,
config: path.resolve(__dirname, '../config.js'),
fs: `${WEB_PLATFORM_ROOT}/stubs/fs.js`,
},
},
};