KonnorRogers / asset_mapper

A tightly scoped directory parser and json file generator.
MIT License
8 stars 0 forks source link

[Feature]: Add a file watcher #1

Open KonnorRogers opened 1 year ago

KonnorRogers commented 1 year ago

not all files should need to be imported by your bundler. Right now to get the most performant bundle you need two entrypoints.

This can get confusing as to "when should I import assets in the app bundle or the asset bundle"

It's also particularly annoying if your bundler doesn't accept glob imports.

As a result, AssetMapper should accept a Rake FileList of files to watch.

AssetMapper.new.configure |config|
   config.file_watcher.files = FileList.new("app/assets")
   config.file_watcher.manifest_file = "public/assets/asset-mapper-manifest.json"
end

importantly the file list should probably exclude CSS and JS assets.

KonnorRogers commented 1 year ago

Im still undecided on this. It adds a lot of complexity, it goes against the mantra of "let your bundler handle your assets", and it introduces 2 ways to handle things.

However, its also reasonable that people may not be using a bundler at all and all they want from AssetMapper is asset fingerprinting.

EDIT: I think I just convinced myself this is needed. It wont do asset compression, minification, etc. Just a simple file hasher.

KonnorRogers commented 1 year ago

Not sure why Sprockets went away from it, but Guard seems like an easy way to handle this.

https://github.com/stevehodgkiss/guard-sprockets2