xfiveco / generator-chisel

Chisel is a development framework for creating easy to maintain and fast WordPress websites.
https://www.getchisel.co
MIT License
270 stars 37 forks source link

devMiddlewareOptions hook should use options.output.base as a publicPath #522

Open piotrkulpinski opened 2 years ago

piotrkulpinski commented 2 years ago

Hi,

I was just trying to move up the src into the theme folder. Not directly, but placed inside a subdirectory named static along with the dist folder.

While everything else went smoothly, I ran into an issue where my local server was not loading the generated static files. After some research I found out, that it's trying to load them from a hardcoded path declared here.

I think it would be a good idea to change that so that it uses the config value set in options.output.base.

As a workaround, I hooked into it directly and changed the publicPath:

hooks: {
  wordPress: {
    devMiddlewareOptions(options) {
      options.publicPath = `/wp-content/themes/${wp.themeName}/static/dist`;
    },
  },
}