Phoenix second node watcher

Hi, guys,
I’m trying to add second phoenix watcher. Completely independent set of CSS, JS, Fonts and images.
So I added

watchers: [
    node: [
      "node_modules/webpack/bin/webpack.js",
      "--mode",
      "development",
      "--watch-stdin",
      cd: Path.expand("../assets", __DIR__)
    ],
    node: [
      "node_modules/webpack/bin/webpack.js",
      "--mode",
      "development",
      "--watch-stdin",
      cd: Path.expand("../theme", __DIR__)
    ]
  ]

And it is working as I expected, generating folder theme in priv/static with all css/img/js content. So far so good this folder content is not accessible via browser. How can I access this folder?

Where does the second watcher output processed files?

priv/static/theme/*
first is standard phoenix processor in priv/static/*

You need to configure plug static to serve theme folder in your endpoint.

But because it’s deeply nested, You need to ensure it is also serving nested folders.

I don’t remember the syntax, but I remember it’s possible :slight_smile:

UPDATE: Try this in your endpoint

  plug Plug.Static,
    at: "/",
    from: :koko,
    gzip: true,
    only: ~w(css fonts images js favicon.ico robots.txt),
    only_matching: ~w(theme)
2 Likes

Thanks a lot. For the moment I mix two assets at /priv/static. Plug is probably reasonable way to do this.