1
|
var webpack = require('webpack');
|
2
|
var path = require('path');
|
3
|
var webpackMerge = require('webpack-merge');
|
4
|
const AotPlugin = require('@ngtools/webpack').AotPlugin;
|
5
|
|
6
|
// Webpack Config
|
7
|
var webpackConfig = {
|
8
|
entry: {
|
9
|
'main': './app/main.ts',
|
10
|
'vendor': './app/vendors.ts',
|
11
|
'polyfills': './app/polyfills.ts',
|
12
|
},
|
13
|
|
14
|
output: {
|
15
|
publicPath: '/dist/',
|
16
|
path: path.resolve(__dirname, './dist'),
|
17
|
},
|
18
|
|
19
|
plugins: [
|
20
|
new webpack.ContextReplacementPlugin(
|
21
|
// The (\\|\/) piece accounts for path separators in *nix and Windows
|
22
|
/angular(\\|\/)core(\\|\/)src(\\|\/)linker/,
|
23
|
path.resolve(__dirname, './'),
|
24
|
{
|
25
|
// your Angular Async Route paths relative to this root directory
|
26
|
}
|
27
|
),
|
28
|
new webpack.ProvidePlugin({
|
29
|
jQuery: 'jquery',
|
30
|
$: 'jquery',
|
31
|
jquery: 'jquery'
|
32
|
}),
|
33
|
new webpack.optimize.CommonsChunkPlugin({
|
34
|
name: ['app', 'vendor', 'polyfills']
|
35
|
})
|
36
|
],
|
37
|
|
38
|
module: {
|
39
|
loaders: [
|
40
|
{test: /\.css$/, loaders: ['to-string-loader', 'css-loader']},
|
41
|
{test: /\.html$/, loader: 'raw-loader'},
|
42
|
{test: /\.scss$/, loaders: ['style', 'css', 'postcss', 'sass']},
|
43
|
{test: /\.(woff2?|ttf|eot|svg)$/, loader: 'url?limit=10000'},
|
44
|
{test: /bootstrap\/dist\/js\/umd\//, loader: 'imports?jQuery=jquery'}
|
45
|
]
|
46
|
},
|
47
|
|
48
|
};
|
49
|
|
50
|
|
51
|
// Our Webpack Defaults
|
52
|
var defaultConfig = {
|
53
|
devtool: 'source-map',
|
54
|
|
55
|
output: {
|
56
|
filename: '[name].bundle.js',
|
57
|
sourceMapFilename: '[name].map',
|
58
|
chunkFilename: '[id].chunk.js'
|
59
|
},
|
60
|
|
61
|
resolve: {
|
62
|
extensions: ['.ts', '.js'],
|
63
|
modules: [path.resolve(__dirname, 'node_modules')]
|
64
|
},
|
65
|
|
66
|
devServer: {
|
67
|
historyApiFallback: true,
|
68
|
watchOptions: {aggregateTimeout: 300, poll: 1000},
|
69
|
headers: {
|
70
|
"Access-Control-Allow-Origin": "*",
|
71
|
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
72
|
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization"
|
73
|
}
|
74
|
},
|
75
|
|
76
|
node: {
|
77
|
global: true,
|
78
|
crypto: 'empty',
|
79
|
__dirname: true,
|
80
|
__filename: true,
|
81
|
process: true,
|
82
|
Buffer: false,
|
83
|
clearImmediate: false,
|
84
|
setImmediate: false
|
85
|
}
|
86
|
};
|
87
|
|
88
|
|
89
|
module.exports = function (env) {
|
90
|
console.log(env);
|
91
|
if ((typeof env == 'undefined') || (!env.release && env.release != true)) {
|
92
|
webpackConfig.plugins.push(
|
93
|
new webpack.DefinePlugin({
|
94
|
"process.env": {
|
95
|
PRODUCTION: JSON.stringify(false),
|
96
|
API_ENDPOINT: JSON.stringify(process.env.API_ENDPOINT || "http://localhost:8080/omtd-registry"),
|
97
|
FAQ_ENDPOINT: JSON.stringify(process.env.FAQ_ENDPOINT || "http://83.212.101.85:5555/api/"),
|
98
|
CONNECTOR_API_ENDPOINT: JSON.stringify(process.env.CONNECTOR_API_ENDPOINT || "http://localhost:8888/content-connector-service"),
|
99
|
WORKFLOW_API_ENDPOINT: JSON.stringify(process.env.WORKFLOW_API_ENDPOINT || "https://dev.openminted.eu:8881"),
|
100
|
OIDC_ENDPOINT: JSON.stringify(process.env.OIDC_ENDPOINT || "http://localhost:8080/omtd-registry/openid_connect_login"),
|
101
|
AAI_ENDPOINT: JSON.stringify(process.env.AAI_ENDPOINT || "https://aai.openminted.eu/oidc")
|
102
|
}
|
103
|
})
|
104
|
);
|
105
|
webpackConfig.module.loaders.push(
|
106
|
{
|
107
|
test: /\.ts$/,
|
108
|
loaders: [
|
109
|
'awesome-typescript-loader',
|
110
|
'angular2-template-loader',
|
111
|
'angular2-router-loader'
|
112
|
]
|
113
|
}
|
114
|
);
|
115
|
} else {
|
116
|
webpackConfig.plugins.push(
|
117
|
new AotPlugin({
|
118
|
tsConfigPath: 'tsconfig.json',
|
119
|
entryModule: path.resolve(__dirname, './app/app.module#AppModule')
|
120
|
})
|
121
|
);
|
122
|
webpackConfig.plugins.push(
|
123
|
new webpack.DefinePlugin({
|
124
|
"process.env": {
|
125
|
PRODUCTION: JSON.stringify(true),
|
126
|
API_ENDPOINT: JSON.stringify("/api"),
|
127
|
FAQ_ENDPOINT: JSON.stringify("/faq"),
|
128
|
CONNECTOR_API_ENDPOINT: JSON.stringify("/connector"),
|
129
|
WORKFLOW_API_ENDPOINT: JSON.stringify("/workflow"),
|
130
|
OIDC_ENDPOINT: JSON.stringify("/api/openid_connect_login"),
|
131
|
AAI_ENDPOINT: JSON.stringify("https://aai.openminted.eu/oidc")
|
132
|
}
|
133
|
})
|
134
|
);
|
135
|
webpackConfig.module.loaders.push(
|
136
|
{
|
137
|
test: /\.ts$/,
|
138
|
loaders: [
|
139
|
'@ngtools/webpack'
|
140
|
]
|
141
|
}
|
142
|
);
|
143
|
}
|
144
|
return webpackMerge(defaultConfig, webpackConfig);
|
145
|
};
|