-
Notifications
You must be signed in to change notification settings - Fork 9
/
webpack.demo.config.js
149 lines (145 loc) · 4.24 KB
/
webpack.demo.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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin")
const SUPPORT_IE = process.env.SUPPORT_IE;
const SPARQL_ENDPOINT = process.env.SPARQL_ENDPOINT;
const WIKIDATA_ENDPOINT = process.env.WIKIDATA_ENDPOINT;
const LOD_PROXY = process.env.LOD_PROXY;
const PROP_SUGGEST = process.env.PROP_SUGGEST;
const aliases = {};
if (!SUPPORT_IE) {
const emptyModule = path.resolve(
__dirname,
'src',
'graph-explorer',
'emptyModule.ts'
);
aliases['canvg-fixed'] = emptyModule;
aliases['es6-promise/auto'] = emptyModule;
}
const examplesDir = path.join(__dirname, 'examples');
const htmlTemplatePath = path.join(__dirname, 'examples', 'template.ejs');
module.exports = {
mode: 'development',
entry: {
rdf: path.join(examplesDir, 'rdf.ts'),
demo: path.join(examplesDir, 'demo.ts'),
dbpedia: path.join(examplesDir, 'dbpedia.ts'),
wikidata: path.join(examplesDir, 'wikidata.ts'),
composite: path.join(examplesDir, 'composite.ts'),
wikidataGraph: path.join(examplesDir, 'wikidataGraph.ts'),
toolbarCustomization: path.join(examplesDir, 'toolbarCustomization.tsx'),
envendpoint: path.join(examplesDir, 'envendpoint.ts'),
},
resolve: {
alias: aliases,
extensions: ['.ts', '.tsx', '.js'],
},
module: {
rules: [
{ test: /\.ts$|\.tsx$/, use: ['ts-loader'] },
{ test: /\.css$/, use: ['style-loader', 'css-loader'] },
{ test: /\.scss$/, use: ['style-loader', 'css-loader', 'sass-loader'] },
{
test: /\.(jpe?g|gif|png|svg)$/,
use: [{ loader: 'url-loader' }],
},
{ test: /\.ttl$/, use: ['raw-loader'] },
],
},
devtool: 'source-map',
optimization: {
splitChunks: {
cacheGroups: {
commons: {
name: 'commons',
chunks: 'initial',
minChunks: 2,
},
},
},
},
output: {
path: path.join(__dirname, 'dist', 'examples'),
filename: '[name].bundle.js',
chunkFilename: '[id].chunk.js',
publicPath: '',
},
plugins: [
new NodePolyfillPlugin(),
new HtmlWebpackPlugin({
filename: 'rdf.html',
title: 'Graph Explorer RDF Demo',
chunks: ['commons', 'rdf'],
template: htmlTemplatePath,
}),
new HtmlWebpackPlugin({
title: 'Graph Explorer Local Demo',
chunks: ['commons', 'demo'],
template: htmlTemplatePath,
}),
new HtmlWebpackPlugin({
filename: 'dbpedia.html',
title: 'Graph Explorer DBPedia SparQL Demo',
chunks: ['commons', 'dbpedia'],
template: htmlTemplatePath,
}),
new HtmlWebpackPlugin({
filename: 'wikidata.html',
title: 'Graph Explorer Wikidata Demo',
chunks: ['commons', 'wikidata'],
template: htmlTemplatePath,
}),
new HtmlWebpackPlugin({
filename: 'wikidataGraph.html',
title: 'Graph Explorer Wikidata with graph Demo',
chunks: ['commons', 'wikidataGraph'],
template: htmlTemplatePath,
}),
new HtmlWebpackPlugin({
filename: 'composite.html',
title: 'Graph Explorer composite DP Demo',
chunks: ['commons', 'composite'],
template: htmlTemplatePath,
}),
new HtmlWebpackPlugin({
filename: 'toolbarCustomization.html',
title: 'Graph Explorer Toolbar Customization Demo',
chunks: ['commons', 'toolbarCustomization'],
template: htmlTemplatePath,
}),
new HtmlWebpackPlugin({
filename: 'envendpoint.html',
title: 'Graph Explorer on $SPARQL_ENDPOINT from env',
chunks: ['commons', 'envendpoint'],
template: htmlTemplatePath,
}),
],
devServer: {
proxy: {
'/sparql**': {
target: SPARQL_ENDPOINT,
pathRewrite: { '/sparql': '' },
changeOrigin: true,
secure: false,
},
'/wikidata**': {
target: WIKIDATA_ENDPOINT || SPARQL_ENDPOINT,
pathRewrite: { '/wikidata': '' },
changeOrigin: true,
secure: false,
},
'/lod-proxy/**': {
target: LOD_PROXY,
changeOrigin: true,
secure: false,
},
'/wikidata-prop-suggest**': {
target: PROP_SUGGEST,
pathRewrite: { '/wikidata-prop-suggest': '' },
changeOrigin: true,
secure: false,
},
},
},
};