inpsyde / composer-asset-compiler

Composer plugin that installs dependencies and compiles assets based on configuration.
https://inpsyde.github.io/composer-asset-compiler/
MIT License
25 stars 1 forks source link

Add ignore lock flag #6

Closed gmazzap closed 3 years ago

gmazzap commented 3 years ago

A new --ignore-lock flag is added to the compile-assets command.

No.

The way the new flag work is documented here: https://github.com/inpsyde/composer-asset-compiler/blob/add-ignore-lock-flag/README.md#ignoring-lock

cristianobaptista commented 3 years ago

@gmazzap after running again my tests, I realized that it might be a good idea to optionally ignore pre-compiled assets or maybe even make it the default because if there are pre-compiled assets, those will be used and no local code changes will be taken into account. What do you think?

gmazzap commented 3 years ago

@cristianobaptista unlike the lock file, pre-compiled assets are opt-in: you need to have specific configuration to make it work.

If no configuration is there, no pre-compiled asset will be used.

When some configuration will be there... it would/should be env-specific, something like this:

{
    "pre-compiled": {
        "env": {
            "prod": {
                "source": "assets-${version}",
                "target": "./assets/",
                "adapter": "gh-release-zip"
            },
            "dev": {
                "source": "assets-${hash}",
                "target": "./assets/",
                "adapter": "gh-action-artifact"
            }
        }
    }
}

With such configuration, unless --env=prod or --env=dev is passed as argument to the composer compile-assets command (or the COMPOSER_ASSET_COMPILER environment variable1 is set to one of those two values), pre-compiled assets would be ignored.

This is why, to be honest, I wouldn't mix the --ignore-lock with pre-compiled assets (and in that case the flag should me renamed to something like --recompile).

Even because, in that case using both --ignore-lock --env=prod would be unclear which one takes precedence.


1 Personally, on my dev machine, I've COMPOSER_ASSET_COMPILER environment variable globally set to local, to have that default value when no --env flag is used.

cristianobaptista commented 3 years ago

@gmazzap sounds reasonable to me. Thanks for your clarification and insights 😁