-
Notifications
You must be signed in to change notification settings - Fork 11
/
webpack.config.js
106 lines (103 loc) · 4.19 KB
/
webpack.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
var webpack = require("webpack");
var path = require("path");
var BUILD_DIR = path.resolve(__dirname, "");
var APP_DIR = path.resolve(__dirname, "");
var version = JSON.stringify(require("./package.json").version);
var config = {
/**
* The key of the object should be what you want the variable to be named after
* the user imports it as a script.
*
* The `import` property tells webpack what file to use as the starting point
* The `filename` property is the name of the bundle file
*/
entry: {
supertokens: {
import: APP_DIR + "/lib/build/bundleEntry.js",
filename: "supertokens.js",
dependOn: "supertokensWebsite",
},
supertokensSession: {
import: APP_DIR + "/lib/build/recipe/session/index.js",
filename: "session.js",
dependOn: "supertokensWebsite",
},
supertokensEmailVerification: {
import: APP_DIR + "/lib/build/recipe/emailverification/index.js",
filename: "emailverification.js",
dependOn: "supertokensWebsite",
},
supertokensEmailPassword: {
import: APP_DIR + "/lib/build/recipe/emailpassword/index.js",
filename: "emailpassword.js",
dependOn: "supertokensWebsite",
},
supertokensThirdParty: {
import: APP_DIR + "/lib/build/recipe/thirdparty/index.js",
filename: "thirdparty.js",
dependOn: "supertokensWebsite",
},
supertokensThirdPartyEmailPassword: {
import: APP_DIR + "/lib/build/recipe/thirdpartyemailpassword/index.js",
filename: "thirdpartyemailpassword.js",
dependOn: "supertokensWebsite",
},
supertokensPasswordless: {
import: APP_DIR + "/lib/build/recipe/passwordless/index.js",
filename: "passwordless.js",
dependOn: "supertokensWebsite",
},
supertokensThirdPartyPasswordless: {
import: APP_DIR + "/lib/build/recipe/thirdpartypasswordless/index.js",
filename: "thirdpartypasswordless.js",
dependOn: "supertokensWebsite",
},
supertokensUserRoles: {
import: APP_DIR + "/lib/build/recipe/userroles/index.js",
filename: "userroles.js",
dependOn: "supertokensWebsite",
},
supertokensMultitenancy: {
import: APP_DIR + "/lib/build/recipe/multitenancy/index.js",
filename: "multitenancy.js",
dependOn: "supertokensWebsite",
},
supertokensMultiFactorAuth: {
import: APP_DIR + "/lib/build/recipe/multifactorauth/index.js",
filename: "multifactorauth.js",
dependOn: "supertokensWebsite",
},
supertokensTOTP: {
import: APP_DIR + "/lib/build/recipe/totp/index.js",
filename: "totp.js",
dependOn: "supertokensWebsite",
},
/**
* The import path is /utils/dateProvider/index.js instead of /lib/build/dateProvider/index.js because the supertokens.js also imports
* the dateProvider from the build folder and that creates a dependency requiring us to load dateprovider.js bundle before supertokens.js.
* However, this issue doesn't happen if we use the /utils/dateProvider/index.js file as import path.
*/
supertokensDateProvider: {
import: APP_DIR + "/utils/dateProvider/index.js",
filename: "dateprovider.js",
dependOn: "supertokensWebsite",
},
/**
* Without this webpack will bundle supertokens-website as independent references
* within each recipe bundle. Any shared resources (WindowHandler for example) will no
* longer be initialised in this case
*
* By separating this and making the recipes depend on this new bundle we ensure that all
* usages of the supertokens-website SDK use the same reference.
*/
supertokensWebsite: {
import: "supertokens-website",
filename: "website.js",
},
},
output: {
path: BUILD_DIR + "/bundle",
library: "[name]",
},
};
module.exports = config;