forked from karlsen-network/node-karlsen-wallet-pwa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
100 lines (100 loc) · 3.42 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
const path = require('path');
const root = __dirname;
const webpack = require("webpack");
const pkg = require("./package.json");
const WorkboxPlugin = require('workbox-webpack-plugin');
const {version, codename} = pkg;
const PWA = {version, codename};
//console.log("webpack.optimize.DedupePlugin", webpack)
let mode = "production";
let watch = false;
//mode = "development"; watch=true;
console.log("MODE:", mode)
module.exports = {
entry: {
//'karlsen-wallet-worker': './http/karlsen-wallet-worker.js',
//'karlsen-wallet':'./http/karlsen-wallet.js'
'wallet-app': './http/wallet-app.js',
'karlsen-wallet-worker-core': './http/karlsen-wallet-worker-core.js'
},
mode,
watch,
/*externals_:{
"/style/style___.js": "/style/style.js",
"/flow/flow-ux/flow-ux.js": "/flow/flow-ux/flow-ux.js",
"/karlsen-ux/karlsen-ux.js": "/karlsen-ux/karlsen-ux.js"
},*/
resolve: {
//importsFields: ["browser"],
//aliasFields: ['browser'],
alias:{
"/style/style.js": "/http/style/style.js",
"/flow/flow-ux/flow-ux.js": path.join(root, "node_modules/@karlsen/flow-ux/flow-ux.js"),
"/flow/flow-ux/src/flow-format.js": path.join(root, "node_modules/@karlsen/flow-ux/src/flow-format.js"),
"/flow/flow-ux/src/base-element.js": path.join(root, "node_modules/@karlsen/flow-ux/src/base-element.js"),
"/flow/flow-ux/src/flow-swipeable.js": path.join(root, "node_modules/@karlsen/flow-ux/src/flow-swipeable.js"),
"/flow/flow-ux/src/flow-i18n.js": path.join(root, "node_modules/@karlsen/flow-ux/src/flow-i18n.js"),
"/@karlsen/ux/karlsen-ux.js": path.join(root, "node_modules/@karlsen/ux/karlsen-ux.js"),
"/@karlsen/grpc-web": path.join(root, "./node_modules/@karlsen/grpc-web"),
"@aspectron/flow-grpc-web": path.join(root, "./node_modules/@aspectron/flow-grpc-web"),
//"karlsen-wallet-worker": "../karlsen-wallet-worker",
//"/karlsen-wallet-worker/karlsen-wallet-worker.js": "../karlsen-wallet-worker/karlsen-wallet-worker.js"
},
fallback: {
"path": false,
"fs": false,
"Buffer": require.resolve("buffer/"),
"buffer": require.resolve("buffer/"),
"url": require.resolve("url/"),
"assert": require.resolve("assert/"),
"process": require.resolve("process/browser"),
"crypto": require.resolve("crypto-browserify"),
"stream": require.resolve("stream-browserify"),
"os": false,
"nw.gui": false,
"@karlsen/wallet-worker": require.resolve("./node_modules/@karlsen/wallet-worker")
}
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist'),
//library:'_LIB',
//libraryTarget: "var"
},
module: {
/*rules: [
// JavaScript / ES6
{
test: /\.js?$/,
//include: path.resolve(__dirname, "../src"),
use: "babel-loader"
}
]*/
},
plugins:[
//new webpack.optimize.DedupePlugin()
new webpack.DefinePlugin({
"window.PWA": JSON.stringify(PWA)
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
process: 'process',
}),
new WorkboxPlugin.GenerateSW({
// these options encourage the ServiceWorkers to get in there fast
// and not allow any straggling "old" SWs to hang around
clientsClaim: true,
skipWaiting: true,
runtimeCaching: [
{
urlPattern: /.*/,
handler: 'NetworkFirst'
}
]
})
],
stats:{
//errorDetails:true,
env:true
}
}