title: integrating bazel and webpack
body: <p>I'm trying to bring webpack into a monorepo that's being built by bazel.</p>
  
  <p>I have something like</p>
  
  <pre><code>source/
  -moduleA/
  -moduleB/
  --package.json
  --static/
  ---image.png
  --source/
  ---foo.ts
  ---bar.js
  ---baz.jsx
  </code></pre>
  
  <p>I've setup my <code>webpack.config.js</code> so that when i run <code>webpack</code> i get something like:</p>
  
  <pre><code>dist/
  -generated.html
  -bundled.js
  -copied/
  --css/
  --img/
  </code></pre>
  
  <p>As far as my knowledge goes this builds a web app. If i serve <code>/dist</code> somehow my browser will load <code>generated.html</code> which will in turn load the other files. </p>
  
  <p>Bazel does not like my <code>/dist</code> dir, but i can't make sense out of all the errors that i've encountered. I'm trying to run something like this</p>
  
  <pre><code>genrule(
    name = "webpack_stuff",
    srcs = [
      ":deps"
    ],
    cmd = " &amp;&amp; ".join([
      "cd source/core/viewer",
      "node node_modules/webpack/bin/webpack.js --config webpack.prod.js --output-path $@",
    ]),
    outs = ["dist"],
    visibility = [
      "//visibility:public",
    ],
  )
  </code></pre>
  
  <p>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. </p>
  
  <p>My expectation was that if i'm able to run <code>npm run build</code> or <code>webpack</code> 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 <code>/dist</code> but still not sure how to make bazel accept it. </p>
  
  <p>Can i somehow tell bazel "make the file <code>webpacked.zip</code> and then use it in your next steps"?</p>
  
  <p>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. </p>