@indiscale/linkahead-webui-ext-map 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +45 -0
- package/.gitlab-ci.yml +44 -0
- package/CHANGELOG.md +78 -0
- package/README.md +97 -0
- package/RELEASE_GUIDELINES.md +45 -0
- package/__mocks__/fileMock.js +3 -0
- package/__mocks__/styleMock.js +1 -0
- package/babel.config.js +22 -0
- package/cypress/e2e/standalone-map.cy.js +55 -0
- package/cypress/support/commands.js +25 -0
- package/cypress/support/e2e.js +17 -0
- package/cypress.config.js +10 -0
- package/dist/2b3e1faf89f94a483539.png +0 -0
- package/dist/416d91365b44e4b4f477.png +0 -0
- package/dist/8f2c4d11474275fbc161.png +0 -0
- package/dist/index.html +1 -0
- package/dist/linkahead-webui-ext-map.js +3 -0
- package/dist/linkahead-webui-ext-map.js.LICENSE.txt +45 -0
- package/dist/linkahead-webui-ext-map.js.map +1 -0
- package/iframe/index.html +6 -0
- package/indiscale-linkahead-webui-ext-map-0.4.1.tgz +0 -0
- package/jest.config.js +23 -0
- package/jest.setup.js +2 -0
- package/package.json +105 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +11 -0
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +25 -0
- package/public/map_tile_caosdb_logo.png +0 -0
- package/public/mock.js +41 -0
- package/public/robots.txt +3 -0
- package/select_query.json +3 -0
- package/src/AllMapEntities.tsx +294 -0
- package/src/CurrentPageEntities.js +318 -0
- package/src/Map.helpers.css +8 -0
- package/src/Map.helpers.js +536 -0
- package/src/Map.js +288 -0
- package/src/Map.test.js +252 -0
- package/src/MapConfig.js +75 -0
- package/src/__snapshots__/Map.test.js.snap +1725 -0
- package/src/components/Coordinates.js +24 -0
- package/src/components/ErrorComponent.tsx +2 -0
- package/src/components/Graticule.js +27 -0
- package/src/components/Loader.module.css +17 -0
- package/src/components/Loader.tsx +36 -0
- package/src/components/PathDropDown.js +108 -0
- package/src/components/SearchControl.js +502 -0
- package/src/components/ToggleMapButton.js +194 -0
- package/src/components/ViewChangeControl.js +104 -0
- package/src/constants/index.js +1 -0
- package/src/context/ConfigProvider.test.js +232 -0
- package/src/context/ConfigProvider.tsx +189 -0
- package/src/context/LoadingProvider.test.js +124 -0
- package/src/context/LoadingProvider.tsx +117 -0
- package/src/context/PathIdProvider.js +102 -0
- package/src/contrib/latlnggraticule/LICENSE +20 -0
- package/src/contrib/latlnggraticule/README.md +68 -0
- package/src/contrib/latlnggraticule/leaflet.latlng-graticule.js +528 -0
- package/src/contrib/simplegraticule/L.Graticule.js +138 -0
- package/src/default_config.json +57 -0
- package/src/global.d.ts +8 -0
- package/src/index.js +6 -0
- package/src/index.scss +133 -0
- package/src/logging.js +7 -0
- package/src/renderHtmlTemplate.test.js +60 -0
- package/src/select-search.min.svg +1 -0
- package/src/select-search.svg +46 -0
- package/src/setupTests.js +5 -0
- package/src/utils/GenerateQueryString.js +200 -0
- package/src/utils/GenerateQueryString.test.js +304 -0
- package/src/utils/index.ts +3 -0
- package/standalone.config.js +5 -0
- package/static/map_tile_caosdb_logo.png +0 -0
- package/tsconfig.json +25 -0
- package/webpack.config.js +193 -0
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { generateQueryString } from "./GenerateQueryString";
|
|
2
|
+
|
|
3
|
+
// Mock the logger used inside generateQueryString
|
|
4
|
+
jest.mock("../logging", () => ({
|
|
5
|
+
logger: {
|
|
6
|
+
error: jest.fn(),
|
|
7
|
+
warn: jest.fn(), // kept for compatibility, but should not be used in strict mode
|
|
8
|
+
info: jest.fn(),
|
|
9
|
+
},
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
import { logger } from "../logging";
|
|
13
|
+
|
|
14
|
+
describe("generateQueryString (strict + optional blocks)", () => {
|
|
15
|
+
const originalLocation = window.location;
|
|
16
|
+
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
// Mock window.location.search
|
|
19
|
+
delete window.location;
|
|
20
|
+
window.location = {
|
|
21
|
+
...originalLocation,
|
|
22
|
+
search: "",
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
jest.clearAllMocks();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
afterAll(() => {
|
|
29
|
+
// Restore original window.location
|
|
30
|
+
window.location = originalLocation;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test("throws when iframeSettings is missing", () => {
|
|
34
|
+
expect(() => generateQueryString(undefined)).toThrow(
|
|
35
|
+
/formatString is required/i
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
expect(logger.warn).not.toHaveBeenCalled();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test("throws when formatString is missing", () => {
|
|
42
|
+
expect(() => generateQueryString({})).toThrow(/formatString is required/i);
|
|
43
|
+
|
|
44
|
+
expect(logger.warn).not.toHaveBeenCalled();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test("replaces a single placeholder with a single URL param (simple case)", () => {
|
|
48
|
+
window.location.search = "?authorId=14104";
|
|
49
|
+
|
|
50
|
+
const iframeSettings = {
|
|
51
|
+
formatString: "SELECT id FROM Dataset HAS AN authors=${authorId}",
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const out = generateQueryString(iframeSettings);
|
|
55
|
+
|
|
56
|
+
expect(out).toBe("SELECT id FROM Dataset HAS AN authors=14104");
|
|
57
|
+
expect(logger.warn).not.toHaveBeenCalled();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test("supports repeated params (no CSV) and consumes them in order", () => {
|
|
61
|
+
window.location.search = "?authorId=14104&authorId=999";
|
|
62
|
+
|
|
63
|
+
const iframeSettings = {
|
|
64
|
+
formatString:
|
|
65
|
+
"SELECT id FROM Dataset HAS AN authors=${authorId} OR authors=${authorId}",
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const out = generateQueryString(iframeSettings);
|
|
69
|
+
|
|
70
|
+
expect(out).toBe(
|
|
71
|
+
"SELECT id FROM Dataset HAS AN authors=14104 OR authors=999"
|
|
72
|
+
);
|
|
73
|
+
expect(logger.warn).not.toHaveBeenCalled();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// ---------------------------------------------------------------------------
|
|
77
|
+
// Optional blocks [[ ... ]]
|
|
78
|
+
//
|
|
79
|
+
// Rules (as requested):
|
|
80
|
+
// - Missing values that are ONLY needed inside optional blocks are OK.
|
|
81
|
+
// - Too many URL values (unused after processing) => throw.
|
|
82
|
+
// - Missing values for non-optional placeholders => throw.
|
|
83
|
+
//
|
|
84
|
+
// Additional rule:
|
|
85
|
+
// - If the template contains EXACTLY ONE optional block, it is repeatable and
|
|
86
|
+
// will be emitted as many times as possible to consume all matching values.
|
|
87
|
+
// ---------------------------------------------------------------------------
|
|
88
|
+
|
|
89
|
+
test("optional block is removed when only one value is provided", () => {
|
|
90
|
+
window.location.search = "?authorId=13967";
|
|
91
|
+
|
|
92
|
+
const iframeSettings = {
|
|
93
|
+
formatString:
|
|
94
|
+
"SELECT id FROM Dataset WITH AN authors=${authorId} [[ OR authors=${authorId} ]]",
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const out = generateQueryString(iframeSettings);
|
|
98
|
+
|
|
99
|
+
// Optional part is removed; allow trailing whitespace differences.
|
|
100
|
+
expect(out.trim()).toBe("SELECT id FROM Dataset WITH AN authors=13967");
|
|
101
|
+
|
|
102
|
+
expect(logger.warn).not.toHaveBeenCalled();
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test("optional block is kept when two values are provided (CSV)", () => {
|
|
106
|
+
window.location.search = "?authorId=13967,14104";
|
|
107
|
+
|
|
108
|
+
const iframeSettings = {
|
|
109
|
+
formatString:
|
|
110
|
+
"SELECT id FROM Dataset WITH AN authors=${authorId} [[ OR authors=${authorId} ]]",
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const out = generateQueryString(iframeSettings);
|
|
114
|
+
|
|
115
|
+
// Keep optional part and fill second authorId.
|
|
116
|
+
expect(out.trim()).toBe(
|
|
117
|
+
"SELECT id FROM Dataset WITH AN authors=13967 OR authors=14104"
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
expect(logger.warn).not.toHaveBeenCalled();
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test("optional block is kept when two values are provided (repeated params)", () => {
|
|
124
|
+
window.location.search = "?authorId=13967&authorId=14104";
|
|
125
|
+
|
|
126
|
+
const iframeSettings = {
|
|
127
|
+
formatString:
|
|
128
|
+
"SELECT id FROM Dataset WITH AN authors=${authorId} [[ OR authors=${authorId} ]]",
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const out = generateQueryString(iframeSettings);
|
|
132
|
+
|
|
133
|
+
expect(out.trim()).toBe(
|
|
134
|
+
"SELECT id FROM Dataset WITH AN authors=13967 OR authors=14104"
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
expect(logger.warn).not.toHaveBeenCalled();
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
test("repeats a single optional block to consume all provided values (strict)", () => {
|
|
141
|
+
// With the repeatable single optional block, this template can consume ALL authorIds.
|
|
142
|
+
window.location.search = "?authorId=13967,14104,14124";
|
|
143
|
+
|
|
144
|
+
const iframeSettings = {
|
|
145
|
+
formatString:
|
|
146
|
+
"SELECT id FROM Dataset WITH AN authors=${authorId} [[ OR authors=${authorId} ]]",
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const out = generateQueryString(iframeSettings);
|
|
150
|
+
|
|
151
|
+
expect(out.trim()).toBe(
|
|
152
|
+
"SELECT id FROM Dataset WITH AN authors=13967 OR authors=14104 OR authors=14124"
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
expect(logger.warn).not.toHaveBeenCalled();
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// ---------------------------------------------------------------------------
|
|
159
|
+
// Strict unused values behavior (non-optional templates)
|
|
160
|
+
// ---------------------------------------------------------------------------
|
|
161
|
+
|
|
162
|
+
test("supports CSV values and fills multiple occurrences in order (unused => throw)", () => {
|
|
163
|
+
window.location.search = "?authorId=14104,999,123";
|
|
164
|
+
|
|
165
|
+
const iframeSettings = {
|
|
166
|
+
formatString:
|
|
167
|
+
"SELECT id FROM Dataset HAS AN authors=${authorId} OR authors=${authorId}",
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
expect(() => generateQueryString(iframeSettings)).toThrow(
|
|
171
|
+
'Unused values for "authorId": 123'
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
expect(logger.warn).not.toHaveBeenCalled();
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test("parses CSV with whitespace and semicolons (unused => throw)", () => {
|
|
178
|
+
// "14104, 999; 123" -> ["14104","999","123"] => unused => throw
|
|
179
|
+
window.location.search = "?authorId=14104,%20999;%20123";
|
|
180
|
+
|
|
181
|
+
const iframeSettings = {
|
|
182
|
+
formatString: "authors=${authorId} OR authors=${authorId}",
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
expect(() => generateQueryString(iframeSettings)).toThrow(
|
|
186
|
+
'Unused values for "authorId": 123'
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
expect(logger.warn).not.toHaveBeenCalled();
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
test("supports a mix of repeated params AND CSV (unused => throw)", () => {
|
|
193
|
+
window.location.search = "?authorId=14104,999&authorId=123";
|
|
194
|
+
|
|
195
|
+
const iframeSettings = {
|
|
196
|
+
formatString: "authors=${authorId} OR authors=${authorId}",
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
expect(() => generateQueryString(iframeSettings)).toThrow(
|
|
200
|
+
'Unused values for "authorId": 123'
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
expect(logger.warn).not.toHaveBeenCalled();
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
test("fills projectId once and repeats the single optional authorId block to consume all authorIds (CSV)", () => {
|
|
207
|
+
window.location.search = "?projectId=abc&authorId=1,2,3,4";
|
|
208
|
+
|
|
209
|
+
const iframeSettings = {
|
|
210
|
+
formatString:
|
|
211
|
+
"SELECT id, name, parent, Event.latitude, Event.longitude FROM Dataset WITH AN projectID=${projectId} AND authors=${authorId} [[ OR authors=${authorId} ]]",
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
const out = generateQueryString(iframeSettings);
|
|
215
|
+
|
|
216
|
+
expect(out).toBe(
|
|
217
|
+
"SELECT id, name, parent, Event.latitude, Event.longitude FROM Dataset WITH AN projectID=abc AND authors=1 OR authors=2 OR authors=3 OR authors=4"
|
|
218
|
+
);
|
|
219
|
+
expect(logger.warn).not.toHaveBeenCalled();
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
test("trims placeholder keys like ${ authorId }", () => {
|
|
223
|
+
window.location.search = "?authorId=14104&authorId=999";
|
|
224
|
+
|
|
225
|
+
const iframeSettings = {
|
|
226
|
+
formatString: "authors=${ authorId } OR authors=${authorId }",
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
const out = generateQueryString(iframeSettings);
|
|
230
|
+
|
|
231
|
+
expect(out).toBe("authors=14104 OR authors=999");
|
|
232
|
+
expect(logger.warn).not.toHaveBeenCalled();
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
test("throws when not enough values are provided for repeated placeholders", () => {
|
|
236
|
+
window.location.search = "?authorId=14104";
|
|
237
|
+
|
|
238
|
+
const iframeSettings = {
|
|
239
|
+
formatString: "authors=${authorId} OR authors=${authorId}",
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
expect(() => generateQueryString(iframeSettings)).toThrow(
|
|
243
|
+
"Missing value for placeholder ${authorId} in URL parameters"
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
expect(logger.warn).not.toHaveBeenCalled();
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
test("keeps queues separate for different placeholder keys (authorId vs projectId)", () => {
|
|
250
|
+
window.location.search = "?authorId=1,2&projectId=abc";
|
|
251
|
+
|
|
252
|
+
const iframeSettings = {
|
|
253
|
+
formatString: "A=${authorId} B=${projectId} C=${authorId} D=${projectId}",
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
expect(() => generateQueryString(iframeSettings)).toThrow(
|
|
257
|
+
"Missing value for placeholder ${projectId} in URL parameters"
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
expect(logger.warn).not.toHaveBeenCalled();
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
test("throws when a placeholder key is not present in the URL at all", () => {
|
|
264
|
+
window.location.search = "?authorId=14104";
|
|
265
|
+
|
|
266
|
+
const iframeSettings = {
|
|
267
|
+
formatString: "authors=${authorId} AND project=${projectId}",
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
expect(() => generateQueryString(iframeSettings)).toThrow(
|
|
271
|
+
"Missing value for placeholder ${projectId} in URL parameters"
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
expect(logger.warn).not.toHaveBeenCalled();
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
test("throws when URL has no params at all", () => {
|
|
278
|
+
window.location.search = "";
|
|
279
|
+
|
|
280
|
+
const iframeSettings = {
|
|
281
|
+
formatString: "authors=${authorId}",
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
expect(() => generateQueryString(iframeSettings)).toThrow(
|
|
285
|
+
"Missing value for placeholder ${authorId} in URL parameters"
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
expect(logger.warn).not.toHaveBeenCalled();
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
test("throws when there are unused values even if all placeholders were filled", () => {
|
|
292
|
+
window.location.search = "?authorId=14104,999";
|
|
293
|
+
|
|
294
|
+
const iframeSettings = {
|
|
295
|
+
formatString: "authors=${authorId}",
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
expect(() => generateQueryString(iframeSettings)).toThrow(
|
|
299
|
+
'Unused values for "authorId": 999'
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
expect(logger.warn).not.toHaveBeenCalled();
|
|
303
|
+
});
|
|
304
|
+
});
|
|
Binary file
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"lib": ["DOM", "ES2020"],
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "Bundler",
|
|
7
|
+
|
|
8
|
+
"jsx": "react-jsx",
|
|
9
|
+
|
|
10
|
+
"strict": false,
|
|
11
|
+
"noImplicitAny": false,
|
|
12
|
+
|
|
13
|
+
"allowJs": true,
|
|
14
|
+
"checkJs": false,
|
|
15
|
+
|
|
16
|
+
"esModuleInterop": true,
|
|
17
|
+
"skipLibCheck": true,
|
|
18
|
+
|
|
19
|
+
"baseUrl": ".",
|
|
20
|
+
"paths": {
|
|
21
|
+
"@/*": ["src/*"]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"include": ["src", "types"]
|
|
25
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
const HTMLWebpackPlugin = require("html-webpack-plugin");
|
|
3
|
+
const webpack = require("webpack");
|
|
4
|
+
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
|
|
5
|
+
|
|
6
|
+
function getEnvVariables(mode) {
|
|
7
|
+
const isDev = mode === "development";
|
|
8
|
+
|
|
9
|
+
const envVars = {
|
|
10
|
+
"process.env.LINKAHEAD_URL": JSON.stringify(
|
|
11
|
+
process.env.LINKAHEAD_URL || (isDev ? "http://localhost:8081" : "")
|
|
12
|
+
),
|
|
13
|
+
"process.env.GRPC_API_URI": JSON.stringify(
|
|
14
|
+
process.env.GRPC_API_URI || (isDev ? "http://localhost:8081/api" : "/api")
|
|
15
|
+
),
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
if (isDev) {
|
|
19
|
+
envVars["process.env.DEVELOPMENT_MODE"] = JSON.stringify(true);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return envVars;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = function (env = {}, argv = {}) {
|
|
26
|
+
const mode = argv.mode || "production";
|
|
27
|
+
|
|
28
|
+
const config = {
|
|
29
|
+
mode,
|
|
30
|
+
entry: path.resolve(__dirname, "./src/index.js"), // JS/TS/TSX entry
|
|
31
|
+
devtool: "source-map",
|
|
32
|
+
|
|
33
|
+
module: {
|
|
34
|
+
rules: [
|
|
35
|
+
{
|
|
36
|
+
test: /\.svg$/,
|
|
37
|
+
use: [
|
|
38
|
+
{
|
|
39
|
+
loader: "svg-url-loader",
|
|
40
|
+
options: { limit: 1000 },
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
// JS/JSX/TS/TSX via Babel
|
|
46
|
+
{
|
|
47
|
+
test: /\.(js|jsx|ts|tsx)$/,
|
|
48
|
+
exclude: /node_modules/,
|
|
49
|
+
use: [
|
|
50
|
+
{
|
|
51
|
+
loader: "babel-loader",
|
|
52
|
+
options: { sourceMap: true },
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
{
|
|
58
|
+
test: /\.s[ac]ss$/i,
|
|
59
|
+
use: [
|
|
60
|
+
"style-loader",
|
|
61
|
+
{ loader: "css-loader", options: { sourceMap: true } },
|
|
62
|
+
{ loader: "sass-loader", options: { sourceMap: true, api: "modern" } },
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
{
|
|
67
|
+
test: /\.module\.css$/,
|
|
68
|
+
use: [
|
|
69
|
+
"style-loader",
|
|
70
|
+
{
|
|
71
|
+
loader: "css-loader",
|
|
72
|
+
options: { sourceMap: true, modules: true },
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
{
|
|
78
|
+
test: /\.css$/i,
|
|
79
|
+
exclude: /\.module\.css$/,
|
|
80
|
+
use: [
|
|
81
|
+
"style-loader",
|
|
82
|
+
{ loader: "css-loader", options: { sourceMap: true } },
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
resolve: {
|
|
89
|
+
// TS extensions added
|
|
90
|
+
extensions: [".ts", ".tsx", ".js", ".jsx"],
|
|
91
|
+
alias: {
|
|
92
|
+
react: path.resolve(__dirname, "./node_modules/react"),
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
output: {
|
|
97
|
+
path: path.resolve(__dirname, "./dist"),
|
|
98
|
+
filename: "linkahead-webui-ext-map.js",
|
|
99
|
+
library: "LinkAheadExtMap",
|
|
100
|
+
libraryTarget: "umd",
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
devServer: {
|
|
104
|
+
port: 8082,
|
|
105
|
+
static: [
|
|
106
|
+
path.resolve(__dirname, "./dist"),
|
|
107
|
+
path.resolve(__dirname, "./static"),
|
|
108
|
+
],
|
|
109
|
+
headers: {
|
|
110
|
+
"Access-Control-Allow-Origin": "*",
|
|
111
|
+
"Access-Control-Allow-Methods":
|
|
112
|
+
"GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
113
|
+
"Access-Control-Allow-Headers":
|
|
114
|
+
"X-Requested-With, content-type, Authorization",
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
externals: {
|
|
119
|
+
react: {
|
|
120
|
+
commonjs: "react",
|
|
121
|
+
commonjs2: "react",
|
|
122
|
+
amd: "React",
|
|
123
|
+
root: "React",
|
|
124
|
+
},
|
|
125
|
+
reactDom: {
|
|
126
|
+
commonjs: "react-dom",
|
|
127
|
+
commonjs2: "react-dom",
|
|
128
|
+
amd: "ReactDom",
|
|
129
|
+
root: "ReactDom",
|
|
130
|
+
},
|
|
131
|
+
"@indiscale/linkahead-webui-core-components": {
|
|
132
|
+
commonjs: "@indiscale/linkahead-webui-core-components",
|
|
133
|
+
commonjs2: "@indiscale/linkahead-webui-core-components",
|
|
134
|
+
amd: "LinkAheadCoreComponents",
|
|
135
|
+
root: "LinkAheadCoreComponents",
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
plugins: [
|
|
140
|
+
new HTMLWebpackPlugin({
|
|
141
|
+
favicon: false,
|
|
142
|
+
showErrors: true,
|
|
143
|
+
cache: true,
|
|
144
|
+
template: path.resolve(__dirname, "public/index.html"),
|
|
145
|
+
}),
|
|
146
|
+
|
|
147
|
+
// Typecheck parallel (Babel transpiles, TS checker checks)
|
|
148
|
+
new ForkTsCheckerWebpackPlugin(),
|
|
149
|
+
],
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
let env_variables = getEnvVariables(mode);
|
|
153
|
+
|
|
154
|
+
if (env["include-peer-deps"]) {
|
|
155
|
+
config.externals = {};
|
|
156
|
+
|
|
157
|
+
console.log("ENV", env_variables);
|
|
158
|
+
config.plugins.push(new webpack.DefinePlugin(env_variables));
|
|
159
|
+
config.plugins.push(
|
|
160
|
+
new webpack.ProvidePlugin({
|
|
161
|
+
process: "process/browser",
|
|
162
|
+
})
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
// If you're mocking in dev mode
|
|
166
|
+
config.entry = path.resolve(__dirname, "./public/mock.js");
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (env["standalone"]) {
|
|
170
|
+
console.log("Package JSON Env", env);
|
|
171
|
+
config.externals = {};
|
|
172
|
+
env_variables = {
|
|
173
|
+
...env_variables,
|
|
174
|
+
"process.env.STANDALONE_MODE": JSON.stringify(true),
|
|
175
|
+
};
|
|
176
|
+
console.log("process.env vars in App", env_variables);
|
|
177
|
+
|
|
178
|
+
config.plugins.push(new webpack.DefinePlugin(env_variables));
|
|
179
|
+
config.plugins.push(
|
|
180
|
+
new webpack.ProvidePlugin({
|
|
181
|
+
process: "process/browser",
|
|
182
|
+
})
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
config.entry = path.resolve(__dirname, "./public/mock.js");
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (!env["include-peer-deps"] && !env["standalone"]) {
|
|
189
|
+
config.plugins.push(new webpack.DefinePlugin(env_variables));
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return config;
|
|
193
|
+
};
|