Comments (5)
Yes, I like this. cc @brenogazzola
from propshaft.
Sure! @rainerborene Could you also post some sample code of this in action?
From what I'm seeing, the resolve_digested_from
will allow us to pass logo.png
and have propshaft find logo-DIGEST-digested.png
. I'm a bit confused about the digested
though. If the builder already generated the file in that format, shouldn't it have already compiled the JS files to replace a reference to logo.png
with logo-DIGEST.digested.png
? This is what happens when we configure webpack/esbuild to generate entryfiles and chunkfiles with the .digested
pattern.
This seems to me something that you’d pass “logo.png”, which is the file the builder wanted, and propshaft would gind “logo-DIGEST.png”, which is what propshaft generated.
from propshaft.
@brenogazzola Not sure if I follow. By digested
you mean the digested_path
helper method, right? If you want we can have a quick call on Zoom.
from propshaft.
Sorry, let me be more specific (we can try zoom if it’s still confusing)
By digested
I meant this line:
pattern = /\A#{filename}-([0-9a-zA-Z]{7,128})\.digested\.#{extname}\z/
I expected it to be:
pattern = /\A#{filename}-([0-9a-zA-Z]{7,128})\.#{extname}\z/
From what I understood of your PR and use case, you have an image file referenced in your JS files as something like logo.png
. When you run rails assets:precompile
, propshaft will rename the file to logo-DIGEST.png
, which means the JS file will not be able to load it. You want to solve that by using a regex to compare file_name
with the assets logical paths in the loadpath. Therefore the extra \.digested
in the regex seems unnecessary to me. File will only have .digested
in their name if the bundler was specifically configured to generate that name. If you are using this new feature in this PR, you are probably not configuring the bunlder to add .digested
(I think?)
from propshaft.
Sorry, let me be more specific (we can try zoom if it’s still confusing)
Same time zone as yours. Plz ping me at rainerborene at gmail dot com.
If you are using this new feature in this PR, you are probably not configuring the bunlder to add .digested (I think?)
Exact the opposite! Take a look at the output
option of the following webpack configuration. As you can see webpack
will generate chunks and assets with the .digested.
suffix on the filename so that propshaft
could understand it and skip the hashing process. The downside is that I cannot link a chunk or asset path using the preload_link_tag
(or any other helper) anymore because it weren't digested by propshaft
in the first place. That's the issue we're trying to solve here.
module.exports = {
output: {
filename: "[name].js",
sourceMapFilename: "[file].map",
chunkFilename: "[name]-[contenthash].digested.js",
assetModuleFilename: "asset-[contenthash].digested[ext]",
path: path.resolve(__dirname, "app/assets/builds"),
}
}
from propshaft.
Related Issues (20)
- Asset digest is computed before compilation HOT 7
- Not able to detect changes in the assets HOT 1
- Raising an error when an asset is not found HOT 4
- config.asset_host as a proc breaks asset paths HOT 1
- quiet_assets initializer breaks when using a custom Rails logger HOT 2
- Using images inside node_modules HOT 3
- Newly added files that are already digested aren't available in development HOT 4
- `assets:clean` task is not cleaning predigested assets with `.digest` in the name HOT 7
- Allow digested files with the same name prefix
- Upgrade doc refers to 'packages.json' HOT 1
- Current version v0.7.0 contains the broken #118 asset_host handling HOT 1
- Revisit Gzip compression support? HOT 15
- SCSS files digested by default HOT 1
- allow a configurable digest length HOT 11
- Using Propshaft::Asset#content with UTF-8 encoding HOT 5
- Add single files to assets compilation HOT 2
- Digests required in dev? HOT 4
- missing require rack/version causing issues with sidekiq HOT 3
- CSS Variable Images HOT 3
- Builds folder not appearing in asset load path causing 'home.css' asset not found error HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from propshaft.