In my Rails app we change the asset prefix and we use a asset host to a static location.
Because multiple rails apps use the same static host we prefix them like this in the initializer:
Rails.application.config.assets.prefix = "/assets/#{Rails.application.class.parent}"
Rails.application.config.assets.manifest = "public#{Rails.application.config.assets.prefix}/sprockets-manifest.json"
This works well for normal rails assets directory. Now we added webpacker to the project and in the webpacker.yml you can't use ERB code like in other yml config files and there is no information available to reconfigure the public_output_path dynamically with initializer config.
I thought ok then it doesn't use the Rails asset configuration so I let the app serve it for now directly from the public dir with ENV['RAILS_SERVE_STATIC_FILES'] enabled. The app runs on domain: app.domain.com and the Rails asset host is set to assets.domain.com. Now I get the url in the html with: https://assets.domain.com/packs/application-a2e1bc1d0db09c347bf4.js. It should use the app.domain.com or use the prefix.
https://app.domain.com/packs/application-a2e1bc1d0db09c347bf4.jshttps://assets.domain.com/RailsAppName/packs/application-a2e1bc1d0db09c347bf4.jsU can try change output.publicPath in production webpack config (config/webpack/production.js) like:
process.env.NODE_ENV = process.env.NODE_ENV || 'production'
const environment = require('./environment')
environment.config.set('output.publicPath', '/prefix/')
module.exports = environment.toWebpackConfig()
This is still a thing :(
@h0jeZvgoxFepBQ2C You can use this master branch: https://github.com/LeftClickBV/swaggard
It contains PR: #49 and #50
Most helpful comment
U can try change output.publicPath in production webpack config (config/webpack/production.js) like: