# Can I add two separate Elm apps to Webpack?

**URL:** <https://discourse.elm-lang.org/t/can-i-add-two-separate-elm-apps-to-webpack/7176>\
**Category:** Learn\
**Created:** [March 29, 2021, 4:38pm UTC](https://discourse.elm-lang.org/t/can-i-add-two-separate-elm-apps-to-webpack/7176 "2021-03-29T16:38:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bdrp](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/bdrp/32/3637_2.png) [@bdrp](https://discourse.elm-lang.org/u/bdrp)\
**Post date:** [March 29, 2021, 4:38pm UTC](https://discourse.elm-lang.org/t/can-i-add-two-separate-elm-apps-to-webpack/7176/1 "2021-03-29T16:38:02Z")

</div>

I’m running an Elixir web server with Webpack. With that I have two separate Elm apps that live and are compiled separately, i.e. it’s two projects with separate elm.json files. So far I’ve compiled them using a make file, but I’d like to incorporate them in Phoenix’s Webpack config file.

This is what I’ve tried so far, and it is failing:

```
entry: {
  'elm-db': './elm-db/src/Main.elm',
  'elm-ledger': './elm-ledger/src/Main.elm',
},
output: {
  filename: '[name].js',
  path: path.resolve(__dirname, '../priv/static/js'),
  publicPath: '/js/',
},
module: {
  rules: [
    {
      test: /\.elm$/,
      exclude: [/elm-stuff/, /node_modules/],
      use: {
        loader: 'elm-webpack-loader',
        options: {
          files: [
            'elm-db/src/Main.elm',
            'elm-ledger/src/Main.elm',
          ].map(name => path.resolve(__dirname, name)),
          debug: options.mode === "development",
          optimize: options.mode === "production",
        },
      },
    },
  ]
},

```

Obviously, Webpack can’t find the corresponding source files for respective project. Compiling two apps to a single javascript file seems easy enough, but I can’t find any instructions how to make Webpack compile to two separate javascript files.

---

<div class="post-metadata">

**Author:** ![Sebastian](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/sebastian/32/98_2.png) [@Sebastian](https://discourse.elm-lang.org/u/Sebastian)\
**Post date:** [March 29, 2021, 9:48pm UTC](https://discourse.elm-lang.org/t/can-i-add-two-separate-elm-apps-to-webpack/7176/2 "2021-03-29T21:48:16Z")

</div>

Yes, we do this. However we use TS files as entry e.g.

```auto
entry: {
  'elm-db': './elm-db/src/main.ts',
  'elm-ledger': './elm-ledger/src/main.ts',
},

```

And the loaders config is just:

```auto
      {
        test: /\.elm$/,
        exclude: [/elm-stuff/, /node_modules/],
        use: {
          loader: "elm-webpack-loader",
          options: {
            cwd: __dirname,
            optimize: ...,
          },
        },
      },

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/1X/50a05e53677a2c3b47776d7abd0f113eb50193a1.png) [@system](https://discourse.elm-lang.org/u/system)\
**Post date:** [April 8, 2021, 9:48pm UTC](https://discourse.elm-lang.org/t/can-i-add-two-separate-elm-apps-to-webpack/7176/3 "2021-04-08T21:48:48Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
