TeaWeb/webpack-client.config.ts

30 lines
955 B
TypeScript
Raw Permalink Normal View History

import * as path from "path";
import * as config_base from "./webpack.config";
export = () => config_base.config("client").then(config => {
Object.assign(config.entry, {
"client-app": "./client/app/index.ts"
});
Object.assign(config.resolve.alias, {
"tc-shared": path.resolve(__dirname, "shared/js"),
/* backend hasn't declared but its available via "require()" */
"tc-backend": path.resolve(__dirname, "shared/backend.d"),
});
if(!Array.isArray(config.externals))
throw "invalid config";
config.externals.push((context, request, callback) => {
2020-09-30 20:51:04 +00:00
if (request.startsWith("tc-backend/")) {
return callback(null, `window["backend-loader"].require("${request}")`);
2020-09-30 20:51:04 +00:00
}
callback(undefined, undefined);
});
config.externals.push({ "jquery": "window.$" });
config.externals.push({ "jsrender": "window.$" });
return Promise.resolve(config);
});