This repository has been archived by the owner on May 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
85 lines (77 loc) · 2.76 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
const webpack = require('@nativescript/webpack');
const path = require('path');
const { ProvidePlugin, NormalModuleReplacementPlugin } = require('webpack');
module.exports = (env) => {
webpack.init(env);
webpack.useConfig('angular');
webpack.chainWebpack((config) => {
// we add the plugin
const fallback = config.resolve.get('fallback');
config.resolve.set(
'fallback',
webpack.Utils.merge(fallback || {}, {
timers: require.resolve('@nativescript/core/'),
fs: require.resolve('@nativescript/core/'),
module: require.resolve('@nativescript/core/'),
path: require.resolve('@nativescript/core/'),
assert: require.resolve("browser-assert"),
buffer: require.resolve("buffer/"),
events: require.resolve("events/"),
// tty: require.resolve("tty-browserify"),
process: require.resolve('process/browser'),
os: require.resolve('os-browserify/browser'),
stream: require.resolve('stream-browserify'),
util: require.resolve("util/"),
// url: require.resolve('url/'),
// BroadcastChannel: false,
crypto: require.resolve('crypto-browserify'),
// // crypto: require.resolve('../libs/crypto/crypto-browserify.js'),
// ws: require.resolve('@master.technology/websockets'),
zlib: false,
// zlib: require.resolve('browserify-zlib'),
http: require.resolve('stream-http'),
https: require.resolve('https-browserify'),
vm: require.resolve('vm-browserify'),
})
);
config.resolve.alias.set(
'pouchdb-md5',
path.resolve(__dirname, './packages/pouchdb-md5')
);
// config.resolve.alias.set(
// 'pouchdb-binary-utils',
// '@craftzdog/pouchdb-binary-utils-react-native'
// );
// config.resolve.alias.set(
// 'pouchdb-core',
// '@craftzdog/pouchdb-core-react-native'
// );
// config.resolve.alias.set('crypto', 'crypto-browserify');
config
.plugin('NormalModuleReplacement|WebsocketPlugin')
.use(
new NormalModuleReplacementPlugin(
/^ws$/,
'@master.technology/websockets'
)
);
config.plugin('ProvidePlugin|Polyfills').use(ProvidePlugin, [
{
Buffer: [require.resolve('buffer/'), 'Buffer'],
crypto: [require.resolve('crypto-browserify/'), 'crypto'],
},
]);
config.plugin('DefinePlugin').tap((args) => {
Object.assign(args[0], {
"process": "global.process",
'process.platform': JSON.stringify('nativescript'),
'process.env': 'global',
'process.env.NODE_DEBUG': false,
'process.version': JSON.stringify('0.0.0'),
'process.browser': true,
});
return args;
});
});
return webpack.resolveConfig();
};