Skip to content

Commit 5bc9996

Browse files
authored
Merge pull request #18 from iteco-labss/feature/remove-workbox-sw
Удалены: Workbox и его SW, webpack-manifest-plugin
2 parents 764c27a + 3372c21 commit 5bc9996

File tree

4 files changed

+13
-1947
lines changed

4 files changed

+13
-1947
lines changed

README.md

Lines changed: 3 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ __Открытие файла__
431431
Метод отправляет клиенту запрос типа:
432432

433433
```
434-
const response = yield openFile(file: {
434+
const response = yield openFile(file: {
435435
"type": <string> | null
436436
"file": <string>
437437
"fileMimeType": <string> | null
@@ -443,9 +443,9 @@ const response = yield openFile(file: {
443443
"fileHash": <string> | null
444444
"fileEncryptionAlgo": <string> | null
445445
"chunkSize": <number> | null
446-
"fileId": <string> | null
446+
"fileId": <string> | null
447447
"key": {} | null
448-
}
448+
}
449449
)
450450
```
451451

@@ -537,77 +537,3 @@ const response = yield requestSelfProfile()
537537
}
538538
}
539539
```
540-
541-
__Кеширование статики с помощью WorkboxWebpackPlugin__
542-
543-
Если приложение было создано с помощью `create-react-app`, добавляем строчку в `package.json`:
544-
545-
```
546-
547-
"scripts": {
548-
"eject": "react-scripts eject",
549-
}
550-
551-
```
552-
553-
В зависимости приложения добавляем `smartapp-sdk` версии `1.2.2` или выше:
554-
555-
```
556-
557-
"dependencies": {
558-
"@unlimited/smartapp-sdk": "^1.2.2",
559-
}
560-
561-
```
562-
563-
Устанавливаем пакет и выполняем команду `npm run eject`.
564-
565-
Далее, делаем следующие изменения в файлах:
566-
567-
Добавляем код в `index.tsx`:
568-
569-
```
570-
571-
if (module.hot) module.hot.accept()
572-
573-
if ("serviceWorker" in navigator) {
574-
window.addEventListener("load", () => {
575-
navigator.serviceWorker.register("./sw.js")
576-
})
577-
}
578-
579-
```
580-
581-
Добавляем код в файл `webpack.config.js`:
582-
583-
```
584-
585-
plugins: [
586-
new WorkboxWebpackPlugin.InjectManifest({
587-
swSrc: "@unlimited/smartapp-sdk/workers/workbox.js", // path to worker
588-
swDest: "sw.js"
589-
}),
590-
591-
```
592-
593-
Удаляем в файле `webpack.config.js` следующий код:
594-
595-
```
596-
597-
// Generate a service worker script that will precache, and keep up to date,
598-
// the HTML & assets that are part of the webpack build.
599-
isEnvProduction &&
600-
fs.existsSync(swSrc) &&
601-
new WorkboxWebpackPlugin.InjectManifest({
602-
swSrc,
603-
dontCacheBustURLsMatching: /\.[0-9a-f]{8}\./,
604-
exclude: [/\.map$/, /asset-manifest\.json$/, /LICENSE/],
605-
// Bump up the default maximum size (2mb) that"s precached,
606-
// to make lazy-loading failure scenarios less likely.
607-
// See <https://github.com/cra-template/pwa/issues/13#issuecomment-722667270>
608-
maximumFileSizeToCacheInBytes: 5 _ 1024 _ 1024,
609-
}),
610-
611-
```
612-
613-
Запускаем приложение, проверяем регистрацию сервис-воркера.

package.json

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,7 @@
3838
"typescript": "^4.0.2"
3939
},
4040
"dependencies": {
41-
"@expressms/smartapp-bridge": "^1.2.1",
42-
"webpack-manifest-plugin": "2.2.0",
43-
"workbox-cacheable-response": "^6.5.4",
44-
"workbox-expiration": "^6.5.4",
45-
"workbox-precaching": "^6.5.4",
46-
"workbox-routing": "^6.5.4",
47-
"workbox-strategies": "^6.5.4",
48-
"workbox-webpack-plugin": "^5.1.4"
41+
"@expressms/smartapp-bridge": "^1.2.1"
4942
},
5043
"files": [
5144
"build/main",
@@ -54,7 +47,6 @@
5447
".npmrc",
5548
"README.md",
5649
"!**/*.spec.*",
57-
"!**/*.json",
58-
"workers/workbox.js"
50+
"!**/*.json"
5951
]
6052
}

workers/workbox.js

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)