I'm trying to bring webpack into a monorepo that's being built by bazel.
I have something like
source/
-moduleA/
-moduleB/
--package.json
--static/
---image.png
--source/
---foo.ts
---bar.js
---baz.jsx
I've setup my webpack.config.js
so that when i run webpack
i get something like:
dist/
-generated.html
-bundled.js
-copied/
--css/
--img/
As far as my knowledge goes this builds a web app. If i serve /dist
somehow my browser will load generated.html
which will in turn load the other files.
Bazel does not like my /dist
dir, but i can't make sense out of all the errors that i've encountered. I'm trying to run something like this
genrule(
name = "webpack_stuff",
srcs = [
":deps"
],
cmd = " && ".join([
"cd source/core/viewer",
"node node_modules/webpack/bin/webpack.js --config webpack.prod.js --output-path $@",
]),
outs = ["dist"],
visibility = [
"//visibility:public",
],
)
I'm not entirely sure what i'm tweaking when i tweak, but at times i get a complaint that "dist" is a directory, other times it complains about working with a read-only file system.
My expectation was that if i'm able to run npm run build
or webpack
without bazel, that i would be able to run it with bazel. This looks like it should be some intermediary step for bazel as it should do something akin to deployment in my layman mind, with the results from webpack. I'm even able to zip all the results in /dist
but still not sure how to make bazel accept it.
Can i somehow tell bazel "make the file webpacked.zip
and then use it in your next steps"?
My research so far yielded few results indicating that this is either very involved or impossible, and most likely not how these tools are supposed to be used. Any help would be most welcome.