Skip to content

Commit 65b908f

Browse files
committed
Clean up webpack
1 parent 212d8f7 commit 65b908f

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

webpack.config.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ const HttpProxyMiddlware = require("http-proxy-middleware");
77
const dfxJson = require("./dfx.json");
88
require("dotenv").config();
99

10-
let localCanister;
11-
12-
try {
13-
localCanister = require("./.dfx/local/canister_ids.json").internet_identity.local;
14-
} catch {}
15-
1610
/**
1711
* Generate a webpack configuration for a canister.
1812
*/
@@ -46,6 +40,15 @@ function generateWebpackConfigForCanister(name, info) {
4640
devServer: {
4741
onBeforeSetupMiddleware: (devServer) => {
4842
let replicaHost = "http://localhost:8000"; // TODO from file
43+
const canisterIdsJson = './.dfx/local/canister_ids.json';
44+
45+
let canisterId;
46+
47+
try {
48+
canisterId = require(canisterIdsJson).internet_identity.local;
49+
} catch (e) {
50+
throw Error(`Could get canister ID from ${canisterIdsJson}: ${e}`);
51+
}
4952

5053
console.log("I am run");
5154
// basically everything _except_ for index.js, because we want live reload
@@ -60,22 +63,19 @@ function generateWebpackConfigForCanister(name, info) {
6063
queryParamsString += `${params}&`;
6164
}
6265

63-
queryParamsString += `canisterId=${localCanister}`;
66+
queryParamsString += `canisterId=${canisterId}`;
6467

6568
return path + queryParamsString;
6669
},
6770

6871
}));
6972
},
7073
port: 8080,
71-
// TODO: why does /authorize redirect to 8081?
72-
//
7374
proxy: {
75+
// Make sure /api calls land on the replica (and not on webpack)
7476
"/api": "http://localhost:8000",
75-
"/authorize": "http://localhost:8081",
7677
},
7778
allowedHosts: [".localhost", ".local", ".ngrok.io"],
78-
//historyApiFallback: true, // makes sure our index is served on all endpoints, e.g. `/faq`
7979
},
8080

8181
// Depending in the language or framework you are using for
@@ -107,7 +107,6 @@ function generateWebpackConfigForCanister(name, info) {
107107
process: require.resolve("process/browser"),
108108
}),
109109
new webpack.EnvironmentPlugin({
110-
"CANISTER_ID": localCanister,
111110
"II_ENV": "production"
112111
}),
113112
new CompressionPlugin({

0 commit comments

Comments
 (0)