forked from paypal/paypal-messaging-components
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.dev.js
More file actions
130 lines (120 loc) · 4.11 KB
/
webpack.config.dev.js
File metadata and controls
130 lines (120 loc) · 4.11 KB
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
const { getWebpackConfig } = require('grumbler-scripts/config/webpack.config');
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 LIBRARY_DEV_CONFIG =
env.TARGET !== 'sdk'
? getWebpackConfig({
entry: {
messaging: './src/index.js'
},
filename: '[name].js',
modulename: ['paypal', 'Messages'],
libraryTarget: 'window',
debug: true,
minify: false,
sourcemaps: true,
env: env.NODE_ENV,
vars: globals(env)
})
: getWebpackConfig({
entry: './paypal.dev.js',
filename: `${FILE_NAME}.js`,
debug: true,
minify: false,
sourcemaps: true,
env: env.NODE_ENV,
vars: {
...globals(env),
__PROTOCOL__: PROTOCOL,
__HOST__: `${HOSTNAME}:${PORT}`,
__SDK_HOST__: `${HOSTNAME}:${PORT}`,
__STAGE_HOST__: 'msmaster.qa.paypal.com',
__PORT__: PORT,
__PATH__: `/${FILE_NAME}.js`,
__NAMESPACE__: 'paypal',
__VERSION__: '1.0.55',
__COMPONENTS__: ['messages']
}
});
LIBRARY_DEV_CONFIG.output.libraryExport = env.TARGET !== 'sdk' ? 'Messages' : '';
LIBRARY_DEV_CONFIG.devServer = {
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 || true,
openPage: (() => {
switch (env.TARGET) {
case 'standalone':
return 'standalone.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 COMPONENTS_DEV_CONFIG = getWebpackConfig({
libraryTarget: 'window',
modulename: 'crc',
debug: true,
minify: false,
sourcemaps: true,
filename: '[name].js',
env: env.NODE_ENV,
vars: globals({
...env,
TARGET: 'components'
})
});
COMPONENTS_DEV_CONFIG.entry = ['US', 'US-EZP', 'DE', 'GB'].reduce(
(accumulator, locale) => ({
...accumulator,
[`smart-credit-modal-${locale}`]: `./src/components/modal/content/${locale}/index.js`
}),
{
'smart-credit-message': './src/components/message/index.js'
}
);
COMPONENTS_DEV_CONFIG.optimization.splitChunks = {
chunks: 'all',
name: 'smart-credit-common'
};
const RENDERING_DEV_CONFIG = getWebpackConfig({
entry: ['./server/index.js'],
libraryTarget: 'commonjs',
modulename: 'renderMessage',
debug: true,
minify: false,
sourcemaps: false,
filename: 'renderMessage.js',
env: env.NODE_ENV,
vars: globals(env)
});
// TODO: Remove this after the ramp
const MODAL_DEV_CONFIG = getWebpackConfig({
entry: './src/old/modal/index.js',
libraryTarget: 'window',
modulename: 'crc',
debug: true,
minify: false,
sourcemaps: true,
filename: 'smart-credit-modal.js',
env: env.NODE_ENV,
vars: globals(env)
});
return [LIBRARY_DEV_CONFIG, COMPONENTS_DEV_CONFIG, RENDERING_DEV_CONFIG, MODAL_DEV_CONFIG];
};