-
Notifications
You must be signed in to change notification settings - Fork 57
/
webpack.config.dev.js
160 lines (150 loc) · 5.19 KB
/
webpack.config.dev.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
const { getWebpackConfig } = require('@krakenjs/webpack-config-grumbler');
const devServerProxy = require('./utils/devServerProxy');
const globals = require('./globals');
const FILE_NAME = 'sdk';
const PROTOCOL = 'https';
const HOSTNAME = 'localhost.paypal.com';
const PORT = process.env.PORT || 8080;
module.exports = (env = {}) => {
const WEBPACK_DEV_SERVER_CONFIG = {
contentBase: './demo',
publicPath: '/',
// set and export DEV_BROWSER in Terminal config to open that specific browser
// otherwise opens default browser if not set
open: process.env.DEV_BROWSER || false,
openPage: (() => {
switch (env.TARGET) {
case 'standalone':
return 'standalone.html';
case 'standalone-modal':
return 'standalone-modal.html';
case 'sdk':
default:
return '';
}
})(),
compress: true,
host: 'localhost.paypal.com',
port: PORT,
overlay: true,
watchContentBase: true,
injectClient: compiler => !!compiler.devServer,
before: devServerProxy,
https: true,
disableHostCheck: true // IE11
};
const LIBRARY_DEV_CONFIG = (() => {
switch (env.TARGET) {
case 'ci': {
return getWebpackConfig({
entry: {
modal: './src/library/modal.js',
messaging: './src/library/messaging.js'
},
filename: '[name].js',
libraryTarget: false,
debug: true,
minify: false,
sourcemaps: true,
env: env.NODE_ENV,
vars: globals(env)
});
}
case 'standalone':
case 'standalone-modal': {
const name = env.TARGET === 'standalone-modal' ? 'modal' : 'messaging';
return getWebpackConfig({
entry: {
[name]: `./src/library/${name}.js`
},
filename: '[name].js',
libraryTarget: false,
debug: true,
minify: false,
sourcemaps: true,
env: env.NODE_ENV,
vars: globals(env)
});
}
case 'sdk':
default:
return getWebpackConfig({
entry: {
[FILE_NAME]: './paypal.dev.js'
},
filename: '[name].js',
debug: true,
minify: false,
sourcemaps: true,
env: env.NODE_ENV,
vars: {
...globals(env),
__PROTOCOL__: PROTOCOL,
__HOST__: `${HOSTNAME}:${PORT}`,
__SDK_HOST__: `${HOSTNAME}:${PORT}`,
__PORT__: PORT,
__PATH__: `/${FILE_NAME}.js`,
__NAMESPACE__: 'paypal',
__VERSION__: '1.0.55',
__COMPONENTS__: ['messages'],
__PAYPAL_DOMAIN__: `${PROTOCOL}://${HOSTNAME}:${PORT}`,
__PAYPAL_API_DOMAIN__: `${PROTOCOL}://${HOSTNAME}:${PORT}`
}
});
}
})();
LIBRARY_DEV_CONFIG.devServer = WEBPACK_DEV_SERVER_CONFIG;
const COMPONENTS_DEV_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',
debug: true,
minify: false,
analyze: env.analyzeComponents,
sourcemaps: true,
filename: '[name].js',
env: env.NODE_ENV,
vars: globals({
...env,
TARGET: 'component'
})
});
const LANDER_COMPONENTS_DEV_CONFIG = getWebpackConfig({
entry: {
'smart-credit-modal-v2-lander': './src/components/modal/v2/index.js'
},
libraryTarget: 'window',
modulename: 'crc',
debug: true,
minify: false,
analyze: env.analyzeComponents,
sourcemaps: true,
filename: '[name].js',
env: env.NODE_ENV,
vars: globals({
...env,
TARGET: 'lander'
})
});
const RENDERING_DEV_CONFIG = getWebpackConfig({
entry: {
renderMessage: './src/server/index.js'
},
libraryTarget: 'commonjs',
modulename: 'renderMessage',
debug: true,
minify: false,
sourcemaps: false,
filename: '[name].js',
env: env.NODE_ENV,
vars: globals({
...env,
TARGET: 'render'
})
});
return [LIBRARY_DEV_CONFIG, COMPONENTS_DEV_CONFIG, LANDER_COMPONENTS_DEV_CONFIG, RENDERING_DEV_CONFIG];
};