An open API service indexing awesome lists of open source software.

https://github.com/cohesivelabs/webpackstaticplug

Phoenix plug to proxy the webpack dev server in order to enable HMR and faster build times during development
https://github.com/cohesivelabs/webpackstaticplug

elixir elixir-lang elixir-phoenix plug webpack webpack-dev-server

Last synced: 3 months ago
JSON representation

Phoenix plug to proxy the webpack dev server in order to enable HMR and faster build times during development

Awesome Lists containing this project

README

          

# WebpackStatic
[![Build Status](https://travis-ci.org/jmartin84/WebpackStaticPlug.svg?branch=master)](https://travis-ci.org/jmartin84/WebpackStaticPlug)

Phoenix plug to proxy a locally running instance of the webpack dev server.

This plug will only serve assets when the env parameter has the value of `:dev`.

Phoenix will be allowed a chance to resolve any assets not resolved by webpack.

## Installation

```elixir
defp deps do
[
{:WebpackStaticPlug, "~> 0.1.1"}
]
end
```

And run:

$ mix deps.get

## Usage
Add WebpackStatic.Plug as a plug in the phoenix project's endpoint.

## Arguments
* **port** - *(required)* The port that the webpack dev server is listening on.
* **webpack_assets** - *(required)* a list of the paths in the static folder that webpack will for serve. The plug will ignore requests to any other path.
* **env** - *(required)* the current environment the project is running under.
* **manifest_path** - *(optional)* relative path that will resolve from the static folder of the webpack manifest file.

## Example
in `endpoint.ex`

```elixir
plug WebpackStatic.Plug,
port: 9000, webpack_assets: ~w(css fonts images js),
env: Mix.env, manifest_path: "/manifest.json"
```