forked from HadoukenIO/fdc3-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
100 lines (95 loc) · 3 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 CopyWebpackPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
function createWebpackConfigForProviderUI() {
return Object.assign({
entry: {
'ui': './src/provider/Selector.tsx'
},
output: {
path: path.resolve(__dirname, './build/ui/pack'),
filename: '[name]-bundle.js'
},
resolve: {
extensions: ['.ts', '.tsx', '.js']
},
devtool:'source-map',
module: {
rules: [
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader
},
"css-loader"
]
},
{
test: /\.(png|jpg|gif|otf|svg)$/,
use: [
{
loader: 'url-loader',
options: {
limit: 8192
}
}
]
},
{
test: /\.tsx?$/,
loader: 'ts-loader'
}
]
},
plugins: [
new MiniCssExtractPlugin({ filename: 'bundle.css' })
]
});
}
/**
* build webpack config for the provider side
* @return {Object} A webpack module
*/
function createWebpackConfigForProvider() {
return {
entry: {
'provider': './staging/provider/index.js'
},
output: {
path: path.resolve(__dirname, './build')
},
plugins: [
new CopyWebpackPlugin([
{ from: './src/ui', to: 'ui/' },
{ from: './src/provider.html' }
]),
new CopyWebpackPlugin([
{ from: './src/app.template.json', to: 'app.json', transform: (content) => {
const config = JSON.parse(content);
const newConfig = prepConfig(config);
return JSON.stringify(newConfig, null, 4);
}}
])
]
};
}
function prepConfig(config) {
const newConf = Object.assign({}, config);
if (typeof process.env.GIT_SHORT_SHA != 'undefined' && process.env.GIT_SHORT_SHA != "" ) {
newConf.startup_app.url = 'https://cdn.openfin.co/services/openfin/fdc3/' + process.env.GIT_SHORT_SHA + '/provider.html';
newConf.startup_app.autoShow = false;
} else if (typeof process.env.CDN_ROOT_URL != 'undefined' && process.env.CDN_ROOT_URL != "" ) {
newConf.startup_app.url = process.env.CDN_ROOT_URL + '/provider.html';
} else {
newConf.startup_app.url = 'http://localhost:3012/provider.html';
}
return newConf;
}
/**
* Modules to be exported
*/
module.exports = [
createWebpackConfigForProvider(),
createWebpackConfigForProviderUI(),
];