Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3509362
D6715.id22816.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D6715.id22816.diff
View Options
diff --git a/lib/webpack/shared.cjs b/lib/webpack/shared.cjs
--- a/lib/webpack/shared.cjs
+++ b/lib/webpack/shared.cjs
@@ -255,4 +255,5 @@
createProdBrowserConfig,
createDevBrowserConfig,
createNodeServerRenderingConfig,
+ getBrowserBabelRule,
};
diff --git a/web/package.json b/web/package.json
--- a/web/package.json
+++ b/web/package.json
@@ -6,7 +6,7 @@
"license": "BSD-3-Clause",
"scripts": {
"clean": "rm -rf dist/ && rm -rf node_modules/",
- "dev": "yarn concurrently --names=\"NODESSR,BROWSER\" -c \"bgBlue.bold,bgMagenta.bold\" \"yarn webpack --config webpack.config.cjs --config-name=server --watch\" \"yarn webpack-dev-server --config webpack.config.cjs --config-name=browser\"",
+ "dev": "yarn concurrently --names=\"NODESSR,BROWSER,WORKERS\" -c \"bgBlue.bold,bgMagenta.bold,bgCyan.bold\" \"yarn webpack --config webpack.config.cjs --config-name=server --watch\" \"yarn webpack-dev-server --config webpack.config.cjs --config-name=browser\" \"yarn webpack --config webpack.config.cjs --config-name=webworkers --watch\"",
"prod": "yarn webpack --config webpack.config.cjs --env prod --progress",
"test": "jest"
},
diff --git a/web/push-notif/service-worker.js b/web/push-notif/service-worker.js
new file mode 100644
--- /dev/null
+++ b/web/push-notif/service-worker.js
@@ -0,0 +1,9 @@
+// @flow
+
+self.addEventListener('install', () => {
+ console.log('service worker installed');
+});
+
+self.addEventListener('activate', () => {
+ console.log('service worker activated');
+});
diff --git a/web/webpack.config.cjs b/web/webpack.config.cjs
--- a/web/webpack.config.cjs
+++ b/web/webpack.config.cjs
@@ -6,6 +6,7 @@
createProdBrowserConfig,
createDevBrowserConfig,
createNodeServerRenderingConfig,
+ getBrowserBabelRule,
} = require('lib/webpack/shared.cjs');
const babelConfig = require('./babel.config.cjs');
@@ -84,6 +85,21 @@
},
};
+const baseWebWorkersConfig = {
+ name: 'webworkers',
+ target: 'webworker',
+ entry: {
+ pushNotif: './push-notif/service-worker.js',
+ },
+ output: {
+ filename: '[name].build.js',
+ path: path.join(__dirname, 'dist', 'webworkers'),
+ },
+ module: {
+ rules: [getBrowserBabelRule(babelConfig)],
+ },
+};
+
module.exports = function (env) {
const browserConfig = env.prod
? createProdBrowserConfig(baseProdBrowserConfig, babelConfig)
@@ -96,5 +112,9 @@
...nodeConfig,
mode: env.prod ? 'production' : 'development',
};
- return [browserConfig, nodeServerRenderingConfig];
+ const webWorkersConfig = {
+ ...baseWebWorkersConfig,
+ mode: env.prod ? 'production' : 'development',
+ };
+ return [browserConfig, nodeServerRenderingConfig, webWorkersConfig];
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 22, 3:49 AM (18 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2690316
Default Alt Text
D6715.id22816.diff (2 KB)
Attached To
Mode
D6715: [web] Add support for web workers to webpack
Attached
Detach File
Event Timeline
Log In to Comment