antikythera v0.4.0 mix antikythera.prepare_assets View Source

Prepares static assets for your gear.

This mix task is called right before compilations of the gear in antikythera's auto-deploy script. It ensures all static assets of your gear reside in priv/static/ directory before compilations of YourGear.Asset module. Assets in priv/static/ directory will then be uploaded to cloud storage for serving via CDN. See Antikythera.Asset for details.

If your gear uses some kind of preprocessing tools to generate asset files (JS, CSS, etc.), you have to set up the supported asset preparation method described in the next section.

Normally you do not have to invoke this mix task when you locally develop your assets. Though you may do so in order to confirm asset preparation is working as you intended.

This mix task invokes the preprocessing tools with ANTIKYTHERA_COMPILE_ENV environment variable (see also Antikythera.Env). You can use this environment variable to distinguish for which environment current script is running.

Supported Asset Preparation Method

Asset preparation process is split into two steps: package installation step and build step. If any part of the preparation process resulted in failure (non-zero exit code), the whole task will abort and thus auto-deploy will fail.

  • Prerequisite: package.json file and antikythera_prepare_assets script in it

Note that if the above prerequisite is not present, the whole asset preparation process will be skipped since package installation is unnecessary.

Package Installation

Use yarn if yarn.lock file exists, otherwise use npm install.

Build using npm-scripts

  • Command: npm run antikythera_prepare_assets
  • Within antikythera_prepare_assets script, you may execute any asset-related actions such as:
    • Linting
    • Type Checking
    • Testing
    • Compiling/Transpiling
    • Uglifying/Minifying
    • etc...
  • How to organize these actions is up to you. You may use whatever tools available in npm, such as webpack or browserify.

Note on implementation

This step is responsible for placing finalized static assets into priv/static/ directory.

In old versions of gear_generator, Node.js packages that depend on compass was used by default in generated gear. compass gem was (and is) globally installed on antikythera jenkins server to enable them.

However, compass is no longer maintained. We recommend you to consider using alternative SASS/SCSS processor. compass gem will be kept installed for backward compatibility.

Link to this section Summary

Link to this section Functions

Link to this function

run_command(cmd, args, env)

View Source

Specs

run_command(String.t(), [String.t()], String.t()) ::
  {String.t(), non_neg_integer(), String.t()}
Link to this function

run_command!(cmd, args, env)

View Source

Specs

run_command!(String.t(), [String.t()], String.t()) :: String.t()