View Source Phoenix.Copy (Phoenix.Copy v0.1.0-rc.1)

Copy static assets for your Phoenix app during development and deployment.

This project was created to manage static asset files. Paired with other standalone build tools like esbuild and tailwind, this can reduce your dependence on JavaScript-based build tools like Webpack.

configuration

Configuration

Before using the project, you must configure one or more profiles. Each profile defines a source and destination for the copy. In config/config.exs, add:

config :phoenix_copy,
  default: [
    source: Path.expand("source/", __DIR__),
    destination: Path.expand("destination/", __DIR__)
  ]

This defines a profile :default. You can define as many profiles as you wish. By using Path.expand/2, you may define the source and destination as paths relative to the configuration file.

direct-usage

Direct Usage

To copy files once, use run/1 with the name of the configured profile:

run(:default)

To watch for changes and continually copy files, use watch/1:

watch(:default)

Note that watch/1 will block execution.

Link to this section Summary

Functions

Returns the configuration of the given profile.

Copies files from the configured source and destination for the given profile.

Watch for changes in the configured source and copy files to the destination.

Link to this section Functions

Specs

config_for!(atom()) :: Keyword.t()

Returns the configuration of the given profile.

Link to this function

run(profile \\ :default)

View Source

Specs

run(atom()) :: [binary()]

Copies files from the configured source and destination for the given profile.

Returns a list of copied files.

Link to this function

watch(profile \\ :default)

View Source

Specs

watch(atom()) :: term()

Watch for changes in the configured source and copy files to the destination.

Also performs an initial copy of the files immediately.