我想从我的回购的一部分在另一部分导入一个打字稿模块,而在我的导入中没有一堆“../..”以返回我的 bazel 工作区的根文件夹。如何为 webpack 设置绝对导入(相对于我的工作区)?我需要在 webpack.config.js 中设置一些东西吗?如果是这样,是什么?
用于说明以下问题的最小设置:
文件夹结构
folder1/
moduleA.ts
BUILD
folder2/
moduleB.ts
BUILD
WORKSPACE
工作空间
workspace(
name = "myworkspace",
)
...
* **模块A.ts ***
// TS COMPILER CAN FIND THIS BUT WEBPACK CAN'T FIND THIS
import { thing } from "myworkspace/folder2/moduleB";
...
文件夹 1/构建
load("@npm_bazel_typescript//:index.bzl", "ts_library")
load("@npm//webpack-cli:index.bzl", webpack = "webpack_cli")
ts_library(
name = "moduleA",
srcs = ["moduleA.ts"],
deps = [
"//folder2:moduleB",
],
)
filegroup(
name = "moduleA.js",
srcs = [
"moduleA",
],
output_group = "es6_sources",
visibility = ["//visibility:public"],
)
webpack(
name = "bundle",
outs = ["app.bundle.js"],
args = [
"$(locations :moduleA.js)",
"--config",
"$(execpath //:webpack.config.js)",
"-o",
"$@",
],
data = [
":moduleA.js",
"//:webpack.config.js",
"@npm//:node_modules",
],
visibility = ["//visibility:public"],
)