forked from molgenis/molgenis-app-biobank-explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
193 lines (184 loc) · 7.05 KB
/
vue.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
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
const webpack = require('webpack')
const BannerPlugin = require('webpack').BannerPlugin
const ZipPlugin = require('zip-webpack-plugin')
const packageJson = require('./package.json')
const GenerateJsonWebpackPlugin = require('generate-json-webpack-plugin')
const MonacoEditorWebpackPlugin = require('monaco-editor-webpack-plugin')
const CopyPlugin = require('copy-webpack-plugin')
const pkgVersion = packageJson.version
const pkgName = packageJson.name
const now = new Date()
const buildDate = now.toUTCString()
const bannerText = `
package-name: ${pkgName}
package-version: ${pkgVersion}
build-date: ${buildDate}`
const previewText = `
package-name: ${pkgName}
build-date: ${buildDate}
PR: ${process.env.CHANGE_ID}
BUILD: ${process.env.BUILD_NUMBER}`
const initialCollectionColumns = require('./src/config/initialCollectionColumns')
const initialBiobankColumns = require('./src/config/initialBiobankColumns')
const initialFilterFacets = require('./src/config/initialFilterFacets')
const i18n = require('./src/config/i18n')
const initialLandingpage = require('./src/config/initialLandingpage')
const htmlTemplate = () => {
if (process.env.NODE_ENV === 'production') return 'apptemplate/app-template.html'
if (process.env.NODE_ENV === 'development') return 'public/index.html'
if (process.env.NODE_ENV === 'test') return 'public/preview.html'
}
const PROXY_TARGET = 'https://bbmri-facts.molgeniscloud.org/'
const apiDevServerProxyConf = {
target: PROXY_TARGET,
keepOrigin: true
}
if (process.env.DATA_EXPLORER_DEV_PW) {
apiDevServerProxyConf.auth = 'admin:' + process.env.DATA_EXPLORER_DEV_PW
}
module.exports = {
runtimeCompiler: true,
outputDir: 'dist',
publicPath: process.env.NODE_ENV === 'production'
? '/plugin/app/' + packageJson.name
: '/',
chainWebpack: config => {
config.resolve.symlinks(false)
config
.plugin('html')
.tap(args => {
args[0].template = htmlTemplate()
args[0].version = process.env.NODE_ENV !== 'production' ? previewText : ''
return args
})
},
configureWebpack: config => {
config.plugins.push(
new MonacoEditorWebpackPlugin({
publicPath: process.env.NODE_ENV !== 'development'
? '/plugin/app/' + pkgName + '/js/' // we need to change this path for webworkers to work on molgenis app
: '/',
languages: ['json'],
features: []
}),
new BannerPlugin({
banner: bannerText
}),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
Popper: ['popper.js', 'default']
}),
new GenerateJsonWebpackPlugin('config.json', {
name: packageJson.name,
label: packageJson.name,
version: `${pkgVersion}`,
description: packageJson.description,
apiDependency: 'v2',
includeMenuAndFooter: true,
runtimeOptions: {
language: 'en',
negotiatorType: 'eric-negotiator',
filterFacets: initialFilterFacets,
collectionColumns: initialCollectionColumns,
biobankColumns: initialBiobankColumns,
biobankCardShowCollections: true,
googleAnalyticsKey: '',
removeFreemarkerMargin: true,
filterMenuInitiallyFolded: false,
applicationNotification: '',
menuHeight: 50,
landingpage: initialLandingpage,
i18n: i18n
}
}, null, 4),
new CopyPlugin({
patterns: [
{ from: 'monaco-files/', to: 'js' } // this is a hack, because we can't load js files from the home dir as app
]
}),
new ZipPlugin({
filename: `${packageJson.name}.v${packageJson.version}`
})
)
},
devServer: {
// In CI mode, Safari cannot contact "localhost", so as a workaround, run the dev server using the jenkins agent pod dns instead.
host: process.env.JENKINS_AGENT_NAME || 'localhost',
// Used to proxy a external API server to have someone to talk to during development
proxy: process.env.NODE_ENV !== 'development' ? undefined : {
'/login': {
target: PROXY_TARGET,
changeOrigin: true
},
// Don't do this on production
'/plugin/directory/export': {
target: 'https://bbmri.accept.molgenis.org/',
changeOrigin: true
},
'/api': {
target: PROXY_TARGET,
changeOrigin: true
},
'/app-ui-context': {
target: PROXY_TARGET,
changeOrigin: true
},
'/logout': {
target: PROXY_TARGET,
changeOrigin: true
},
'/plugin/app/molgenis-app-biobank-explorer/img/': {
secure: false,
pathRewrite: { '^/plugin/app/molgenis-app-biobank-explorer': '' }, /** removes the part of the url, so this will go straight to /img in public folder */
target: 'http://localhost:8080'
}
},
// Used as mock in e2e tests
before: process.env.NODE_ENV !== 'test' ? undefined : function (app) {
app.get('/app-ui-context', function (req, res) {
res.json(require('./tests/e2e/resources/uiContext.js'))
})
app.get('/api/metadata/root_hospital_diagnosis', function (req, res) {
res.json(require('./tests/e2e/resources/v3/metadata_root_hospital_diagnosis.js'))
})
app.get('/api/metadata/root_hospital_lab_results', function (req, res) {
res.json(require('./tests/e2e/resources/v3/metadata_root_hospital_lab_results.js'))
})
app.get('/api/metadata/root_cities', function (req, res) {
res.json(require('./tests/e2e/resources/v3/metadata_root_cities.js'))
})
app.get('/api/metadata/root_gender', function (req, res) {
res.json(require('./tests/e2e/resources/v3/metadata_root_gender.js'))
})
app.get('/api/metadata/root_hospital_users', function (req, res) {
res.json(require('./tests/e2e/resources/v3/metadata_root_hospital_users.js'))
})
app.get('/api/metadata/root_hospital_patients', function (req, res) {
res.json(require('./tests/e2e/resources/v3/metadata_root_hospital_patients_flat.js'))
})
app.get('/api/metadata/TableWithCustomCard', function (req, res) {
res.json(require('./tests/e2e/resources/v3/metadata_root_hospital_patients_flat.js'))
})
app.get('/api/data/root_hospital_patients/p000000001', function (req, res) {
res.json(require('./tests/e2e/resources/v3/data_p00001'))
})
app.get('/api/data/root_hospital_patients', function (req, res) {
res.json(require('./tests/e2e/resources/typeTestData.js'))
})
app.get('/api/data/de_dataexplorer_table_settings', function (req, res) {
if (req.url.includes('TableWithMoreColumns')) {
res.json({ items: [] })
} else if (req.url.includes('TableWithCustomCard')) {
res.json(require('./tests/e2e/resources/tableSettingsWithCustom'))
} else {
res.json(require('./tests/e2e/resources/tableSettings.js'))
}
})
app.get('/api/data/TableWithCustomCard', function (req, res) {
res.json(require('./tests/e2e/resources/tableWithMoreColumns.js'))
})
}
}
}