Build and distribution
Since Wordless is using Webpack, we have to manage build and distribution strategies for dev and staging/production.
Most spread folder naming to distinguish between source and built code are
dst, but Wordless has different naming due to backword
Source assets' code is placed in
is placed - automatically by Webpack - in
.. seealso:: :ref:`CoffeeScript and Sass`
We offer standard approarches for both the environments. They are handled -
as expected - through
package.json 's scripts :
It is expected - but up to you - that before every build you will clean compiled files
Build for development
yarn clean:dist && yarn build:dev
Build for production
yarn clean:dist && yarn build:prod
Production build will essentially
- enable Webpack's production mode
- do not produce source maps
- do minimize assets
When performance is a goal, PHUG ships a built-in Optimizer. You can read about it in the phug documentation:
The Optimizer is a tool that avoid to load the Phug engine if a file is available in the cache. In counterpart, it does not allow to change the adapter or user post-render events.
Wordless supports enabling this important optimization by setting an
environment variable (in any way supported by your system) or a global
constant to be defined in
wp-config.php. Let's see this Wordless'
internal code snippet:
.. literalinclude:: /../../wordless/helpers/render_helper.php :lines: 81-87,89-91 :language: php :caption: render_helper.php
where we search for
ENVIRONMENT and thus we'll activate PHUG's
Optimizer if the value will be
Arbitrary values are not supported.
The simplest approach is to to define a constant inside
Wordless is agnostic about deploy strategy. Our favourite product to deploy WordPress is Wordmove.