forked from metabase/metabase
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrspack.iframe-sdk-embed.config.js
More file actions
83 lines (75 loc) · 2.18 KB
/
Copy pathrspack.iframe-sdk-embed.config.js
File metadata and controls
83 lines (75 loc) · 2.18 KB
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
/* eslint-disable import/no-commonjs */
/* eslint-disable no-undef */
const path = require("path");
const {
CopyJsFromTmpDirectoryPlugin,
} = require("./frontend/build/shared/rspack/copy-js-from-tmp-directory-plugin");
const ENTERPRISE_SRC_PATH =
__dirname + "/enterprise/frontend/src/metabase-enterprise";
const SCRIPT_TAG_PATH = path.resolve(
ENTERPRISE_SRC_PATH,
"embedding_iframe_sdk/embed.ts",
);
const BUILD_PATH = __dirname + "/resources/frontend_client";
const EMBEDDING_SRC_PATH = __dirname + "/enterprise/frontend/src/embedding";
const SDK_BUNDLE_SRC_PATH =
__dirname + "/enterprise/frontend/src/embedding-sdk-bundle";
const OUT_FILE_NAME = "embed.js";
const OUT_TEMP_PATH = path.resolve(BUILD_PATH, "tmp-embed-js");
const DEV_PORT = process.env.MB_FRONTEND_DEV_PORT || 8080;
module.exports = {
name: "iframe_sdk_embed_v1",
entry: SCRIPT_TAG_PATH,
output: {
// we must use a different directory than the main rspack config,
// otherwise the path conflicts and the output bundle will not appear.
path: OUT_TEMP_PATH,
filename: OUT_FILE_NAME,
library: "metabase.embed",
libraryTarget: "umd",
globalObject: "this",
publicPath: `http://localhost:${DEV_PORT}/app`,
},
devServer: { hot: false },
module: {
rules: [
{
test: /\.(ts|js)$/,
use: [
{
loader: "builtin:swc-loader",
options: {
jsc: {
loose: true,
transform: {},
parser: { syntax: "typescript" },
},
sourceMaps: false,
minify: false,
env: { targets: ["defaults"] },
},
},
],
type: "javascript/auto",
},
],
},
optimization: { splitChunks: false, runtimeChunk: false },
devtool: false,
plugins: [
CopyJsFromTmpDirectoryPlugin({
fileName: OUT_FILE_NAME,
tmpPath: OUT_TEMP_PATH,
outputPath: path.join(BUILD_PATH, "app/"),
copySourceMap: false,
cleanupInDevMode: true,
}),
],
resolve: {
extensions: [".js", ".ts"],
alias: {
embedding: EMBEDDING_SRC_PATH,
"embedding-sdk-bundle": SDK_BUNDLE_SRC_PATH,
},
},
};