1
1
const webpack = require ( 'webpack' )
2
2
const path = require ( 'path' )
3
+ const CopyPlugin = require ( 'copy-webpack-plugin' )
3
4
const HtmlWebpackPlugin = require ( 'html-webpack-plugin' )
5
+ const WorkboxPlugin = require ( 'workbox-webpack-plugin' )
4
6
// https://webpack.js.org/guides/production/
5
7
6
8
const config = {
@@ -18,9 +20,11 @@ const config = {
18
20
) , // Hack to allow creating the client in a browser
19
21
express : false ,
20
22
net : 'net-browserify' ,
21
- fs : 'memfs'
23
+ fs : 'memfs' ,
24
+ jose : false
22
25
} ,
23
26
fallback : {
27
+ jose : false ,
24
28
zlib : require . resolve ( 'browserify-zlib' ) ,
25
29
stream : require . resolve ( 'stream-browserify' ) ,
26
30
buffer : require . resolve ( 'buffer/' ) ,
@@ -55,32 +59,27 @@ const config = {
55
59
new webpack . NormalModuleReplacementPlugin (
56
60
/ p r i s m a r i n e - v i e w e r [ / | \\ ] v i e w e r [ / | \\ ] l i b [ / | \\ ] u t i l s / ,
57
61
'./utils.web.js'
58
- )
59
- ] ,
60
- // The directories that can be optionally symlinked
61
- [ Symbol . for ( 'webpack_directories' ) ] : [
62
- { from : path . join ( __dirname , '/node_modules/prismarine-viewer/public/blocksStates/' ) , to : './blocksStates/' } ,
63
- { from : path . join ( __dirname , '/node_modules/prismarine-viewer/public/textures/' ) , to : './textures/' } ,
64
- { from : path . join ( __dirname , 'extra-textures/' ) , to : './extra-textures/' }
65
- ] ,
66
- // The files that will be copied
67
- [ Symbol . for ( 'webpack_files' ) ] : [
68
- { from : path . join ( __dirname , '/styles.css' ) , to : './styles.css' } ,
69
- { from : path . join ( __dirname , '/node_modules/prismarine-viewer/public/worker.js' ) , to : './' } ,
70
- { from : path . join ( __dirname , '/node_modules/prismarine-viewer/public/supportedVersions.json' ) , to : './' } ,
71
- { from : path . join ( __dirname , 'assets/' ) , to : './' } ,
72
- { from : path . join ( __dirname , 'config.json' ) , to : './config.json' }
73
- ] ,
74
- module : {
75
- rules : [
76
- {
77
- test : / \. m ? j s / ,
78
- resolve : {
79
- fullySpecified : false
80
- }
81
- }
82
- ]
83
- }
62
+ ) ,
63
+ new WorkboxPlugin . GenerateSW ( {
64
+ // these options encourage the ServiceWorkers to get in there fast
65
+ // and not allow any straggling "old" SWs to hang around
66
+ clientsClaim : true ,
67
+ skipWaiting : true ,
68
+ include : [ 'index.html' , 'manifest.json' ] // not caching a lot as anyway this works only online
69
+ } ) ,
70
+ new CopyPlugin ( {
71
+ patterns : [
72
+ { from : path . join ( __dirname , '/styles.css' ) , to : './styles.css' } ,
73
+ { from : path . join ( __dirname , '/node_modules/prismarine-viewer/public/blocksStates/' ) , to : './blocksStates/' } ,
74
+ { from : path . join ( __dirname , '/node_modules/prismarine-viewer/public/textures/' ) , to : './textures/' } ,
75
+ { from : path . join ( __dirname , '/node_modules/prismarine-viewer/public/worker.js' ) , to : './' } ,
76
+ { from : path . join ( __dirname , '/node_modules/prismarine-viewer/public/supportedVersions.json' ) , to : './' } ,
77
+ { from : path . join ( __dirname , 'assets/' ) , to : './' } ,
78
+ { from : path . join ( __dirname , 'extra-textures/' ) , to : './extra-textures/' } ,
79
+ { from : path . join ( __dirname , 'config.json' ) , to : './config.json' }
80
+ ]
81
+ } )
82
+ ]
84
83
}
85
84
86
85
module . exports = config
0 commit comments