Is there a expose-dev or similar for composer?

Silverstripe Version: SS4.13 (but soon to be upgraded to SS5

Question:

I have a project which uses a source theme in dev, then builds completed theme files to use when live - this is currently working just fine, aside from a little composer caveat. I currently have assets for both themes exposed in composer.json, however I’d like to only expose the live theme assets when live.

Is there an extra-dev or expose-dev option that works similar to require-dev in composer.json?

eg. something like this:

"extra": {
        "resources-dir": "_resources",
        "expose": [
            "themes/my_live_theme/assets"
        ],
       "expose-dev": [
            "themes/my_source_theme/src/assets",
            "themes/my_source_theme/node_modules/bootstrap-icons",
            "themes/my_source_theme/node_modules/swiper",
            "themes/my_source_theme/node_modules/bootstrap/dist"
        ],
        "project-files-installed": [
            "app/.htaccess",
            "app/_config.php",
            "app/_config/mimevalidator.yml",
            "app/_config/mysite.yml",
            "app/src/Page.php",
            "app/src/PageController.php"
        ],
        "public-files-installed": [
            ".htaccess",
            "index.php",
            "web.config"
        ]
    },

Any help or suggestions greatly appreciated!

The exposed files are environment-unaware… it doesn’t happen at request-time, so there can be no decision-making on what to do.

What’s the harm in having the “dev” files available? Their existence isn’t broadcast anywhere, and provided you don’t have directory listings available on your web server, then it should be pretty tricky to stumble across them accidentally.

The dev files aren’t uploaded to the live version, so composer vendor-expose copy gives an error during the deployment process. I can of course edit composer.json every time I deploy, I was just wondering if there’s not a more elegant solution available out there…

For maximum convenience, I personally use deployer with a variant of this script. Then adding a per-project .rsync-filter allows me to decide what I don’t want to be uploaded.

On a successful configuration, dep deploy is the only thing I need to do. Locally you can have whatever you want but the destination host shouldn’t even know you are using node.

1 Like

@ntd I totally agree! Thanks for the suggestions.