-
Notifications
You must be signed in to change notification settings - Fork 57
/
webpack.config.js
111 lines (102 loc) · 3.11 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
101
102
103
104
105
106
107
108
109
110
111
const { getWebpackConfig } = require('@krakenjs/webpack-config-grumbler');
const globals = require('./globals');
module.exports = (env = {}) => {
// messaging.js
const MESSAGING_JS_CONFIG = getWebpackConfig({
entry: {
messaging: './src/library/messaging.js'
},
filename: '[name].js',
// Need to explicitly disable this feature. The library has it's own
// window bootstrap mechanism to attach multiple "exports" onto window.paypal
libraryTarget: false,
web: true,
minify: true,
debug: false,
analyze: env.analyze,
env: env.NODE_ENV,
vars: globals({
...env,
TARGET: 'standalone'
})
});
const MODAL_JS_CONFIG = getWebpackConfig({
entry: {
modal: './src/library/modal.js'
},
filename: '[name].js',
// Need to explicitly disable this feature. The library has it's own
// window bootstrap mechanism to attach multiple "exports" onto window.paypal
libraryTarget: false,
web: true,
minify: true,
debug: false,
analyze: env.analyze,
env: env.NODE_ENV,
vars: globals({
...env,
TARGET: 'standalone-modal'
})
});
// zoid components
const COMPONENTS_CONFIG = getWebpackConfig({
entry: {
'smart-credit-message': './src/components/message/index.js',
'smart-credit-modal-v2': './src/components/modal/v2/index.js',
'smart-credit-modal-US-EZP': `./src/components/modal/v1/content/US-EZP/index.js`
},
libraryTarget: 'window',
modulename: 'crc',
web: true,
minify: true,
debug: false,
analyze: env.analyzeComponents,
filename: '[name].js',
env: env.NODE_ENV,
vars: globals({
...env,
TARGET: 'component'
})
});
const LANDER_COMPONENTS_CONFIG = getWebpackConfig({
entry: {
'smart-credit-modal-v2-lander': './src/components/modal/v2/index.js'
},
libraryTarget: 'window',
modulename: 'crc',
web: true,
minify: true,
debug: false,
analyze: env.analyzeComponents,
filename: '[name].js',
env: env.NODE_ENV,
vars: globals({
...env,
TARGET: 'lander'
})
});
const RENDERING_CONFIG = getWebpackConfig({
entry: {
renderMessage: './src/server/index.js'
},
libraryTarget: 'commonjs',
modulename: 'renderMessage',
minify: true,
debug: false,
filename: '[name].js',
env: env.NODE_ENV,
vars: globals({
...env,
TARGET: 'render'
})
});
const modules = {
library: [MESSAGING_JS_CONFIG, MODAL_JS_CONFIG],
components: [COMPONENTS_CONFIG, LANDER_COMPONENTS_CONFIG],
render: [RENDERING_CONFIG]
};
return Array.prototype.concat.apply(
[],
(env.MODULE || 'library,components,render').split(',').map(module => modules[module])
);
};