Sage 9 assets path in wordpress subfolder installation

I’m doing yarn build:production for a deploy in a production server that is in a subfolder installation (/v2) but in local I’m running in /

Is there a way to tell webpack to build the assets path to that /v2/ folder?

I’m getting /wp-content/themes/fedesam/dist/images/image.png in my dist/style files but I need to be /v2/wp-content/themes/fedesam/dist/images/image.png

Thanks!

Edit the public path field in your config.json to be /v2/wp-content/themes/themeName. If u want different paths setup for each one then this may help

1 Like

You can set the public path dynamically from the command line without modifying Sage’s build process by setting SAGE_DIST_PATH:

2 Likes

Hi. This is exactly what I’ve been looking for as my staging is in a sub folder and assets that are called from CSS (fonts and bg images) are missing the subfolder name in the path. I feel rather awkward asking, but how do you implement this. I tried uncommenting this section in the config file but of course this errors. I’m sure it’s simple. Cheers.

What do I do with this?
SAGE_DIST_PATH=/subfolder/wp-content/themes/sage/dist/ yarn build:production

Hi pallan! In the file package.json you have to modify that line in the script section:

"scripts": {
...
    "build:production": "SAGE_DIST_PATH=/subfolder/wp-content/themes/fedesam/dist/ webpack --env.production --progress --config resources/assets/build/webpack.config.js",
...
}
1 Like

Thanks. Much appreciated.