11/* eslint-disable @typescript-eslint/no-var-requires */
22const withPWA = require ( 'next-pwa' ) ;
3+ const withTM = require ( 'next-transpile-modules' ) ( [ 'typeorm/browser' ] ) ;
4+ const webpack = require ( 'webpack' ) ;
35const defaultCache = require ( 'next-pwa/cache' ) ;
46const envMapping = require ( './configs/env.mapping' ) ;
57
@@ -17,51 +19,69 @@ const encodeUriTransform = async (manifestEntries) => {
1719} ;
1820
1921module . exports = ( ) =>
20- withPWA ( {
21- env : envMapping ,
22- target : 'serverless' ,
23- poweredByHeader : false ,
24- assetPrefix : LINK_PREFIX ,
22+ withPWA (
23+ withTM ( {
24+ webpack : ( config , { isServer } ) => {
25+ config . plugins . push (
26+ new webpack . ProvidePlugin ( {
27+ 'window.SQL' : 'sql.js/dist/sql-wasm.js' ,
28+ } )
29+ ) ;
30+ if ( ! isServer ) {
31+ config . node = {
32+ fs : 'empty' ,
33+ net : 'empty' ,
34+ tls : 'empty' ,
35+ } ;
36+ }
37+ return config ;
38+ } ,
2539
26- pwa : {
27- disable : ! isProd ,
28- subdomainPrefix : LINK_PREFIX ,
29- dest : 'public' ,
30- manifestTransforms : [ encodeUriTransform ] ,
31- runtimeCaching : [
32- ...defaultCache ,
33- {
34- urlPattern : / ^ h t t p s ? .* / ,
35- handler : 'NetworkFirst' ,
36- options : {
37- cacheName : 'offlineCache' ,
38- networkTimeoutSeconds : 15 ,
39- expiration : {
40- maxEntries : 150 ,
41- maxAgeSeconds : 30 * 24 * 60 * 60 ,
42- } ,
43- cacheableResponse : {
44- statuses : [ 0 , 200 ] ,
40+ env : envMapping ,
41+ target : 'serverless' ,
42+ poweredByHeader : false ,
43+ assetPrefix : LINK_PREFIX ,
44+
45+ pwa : {
46+ disable : ! isProd ,
47+ subdomainPrefix : LINK_PREFIX ,
48+ dest : 'public' ,
49+ manifestTransforms : [ encodeUriTransform ] ,
50+ runtimeCaching : [
51+ ...defaultCache ,
52+ {
53+ urlPattern : / ^ h t t p s ? .* / ,
54+ handler : 'NetworkFirst' ,
55+ options : {
56+ cacheName : 'offlineCache' ,
57+ networkTimeoutSeconds : 15 ,
58+ expiration : {
59+ maxEntries : 150 ,
60+ maxAgeSeconds : 30 * 24 * 60 * 60 ,
61+ } ,
62+ cacheableResponse : {
63+ statuses : [ 0 , 200 ] ,
64+ } ,
4565 } ,
4666 } ,
47- } ,
48- {
49- urlPattern : ( { event } ) => event . request . mode === 'navigate ',
50- handler : 'CacheFirst' ,
51- options : {
52- cacheName : 'offlineCache' ,
53- expiration : {
54- maxEntries : 150 ,
55- maxAgeSeconds : 30 * 24 * 60 * 60 ,
56- } ,
57- cacheableResponse : {
58- statuses : [ 0 , 200 ] ,
67+ {
68+ urlPattern : ( { event } ) => event . request . mode === 'navigate' ,
69+ handler : 'CacheFirst ',
70+ options : {
71+ cacheName : 'offlineCache' ,
72+ expiration : {
73+ maxEntries : 150 ,
74+ maxAgeSeconds : 30 * 24 * 60 * 60 ,
75+ } ,
76+ cacheableResponse : {
77+ statuses : [ 0 , 200 ] ,
78+ } ,
5979 } ,
6080 } ,
61- } ,
62- ] ,
63- navigationPreload : true ,
64- // publicExcludes : [],
65- // exclude: ['**/node_modules/**/*'] ,
66- } ,
67- } ) ;
81+ ] ,
82+ navigationPreload : true ,
83+ // publicExcludes: [] ,
84+ // exclude : ['**/node_modules/**/*' ],
85+ } ,
86+ } )
87+ ) ;
0 commit comments