-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inject ASSET_HOST in runtime, instead of compile time #1080
Comments
can you unset That should be enough to get relative paths in the manifest and then you can use these along with |
Oh, I see the problem, in here we are assuming a |
Another side effect of this is that the assets compiled by Webpacker can't be used in emails if you have a different asset host for Action Mailer. Since the manifest already includes URLs with host, |
After having a quick look at generated manifest.js file, seems host name is not included, so rails know how to inject CDN domain correctly into the assets under pack folder in runtime. but is it possible we can do the same things in the any scss file using |
As mentioned in the Webpack documentation for Public Path, you can set the effective public path at runtime by setting the global variable However, that will only work if the Webpacker currently passes the I did a proof of concept to show that you can set the asset host at runtime by deleting that option, although changing the built-it loader config is a little awkward. Feel free to use my demo repo for reproducing/testing a fix, or copy the solution to your own apps until webpacker has a fix. I got the runtime resolution working in this commit : joshuaflanagan/webpacker-demo@6fec15b. |
@gauravtiwari After this fix I am facing another problem: I haven't checked with webpack-dev-server though. |
FYI I was able to get webpacker to work with |
Hi, all:
I am trying to migrate my whole asset from asset pipeline into webpack.
I have a issue while using CDN with webpacker, which do not happen in asset pipeline.
This is one of my scss file
while compile asset, I was using a
staging
env, which is fine, one of env variable is ASSET_HOST or WEBPACK_ASSET_HOST in latest master branch, which point to my staging CDN. and it compile to:Everything is correct here, but can we compile to a relative path so that we can inject ASSET_PATH within rails system in run time?
BTW: I have a use case here: my app is building within a docker image and I only build images once for both staging & production, so while building this image, and run
assets:precompile
,RAILS_ENV
is point toproduction
. this is working as asset pipeline only refer toconfig.action_controller.asset_host
for CDN in different env, but inwebpacker
, seems CDN host is injected in compile time, and can not changed in run time.Is there anyway to change the behaviour?
The text was updated successfully, but these errors were encountered: