Is there any existing tool to auto rename assets files in transformer?

27 views
Skip to first unread message

Kun Li

unread,
Dec 16, 2014, 1:00:26 PM12/16/14
to mi...@dartlang.org
Hey Dartisans:

Adding signature into file name of assets file(css/js/etc) is a common practice to make sure any change to these files will be delivered without worrying about cache. I'm wondering in Dart world, how do people usually do it? Is there any existing tool for that to be included in transformer?

Thanks!

Bob Nystrom

unread,
Dec 16, 2014, 1:48:22 PM12/16/14
to General Dart Discussion

On Tue, Dec 16, 2014 at 10:00 AM, Kun Li <likunar...@gmail.com> wrote:
Adding signature into file name of assets file(css/js/etc) is a common practice to make sure any change to these files will be delivered without worrying about cache. I'm wondering in Dart world, how do people usually do it? Is there any existing tool for that to be included in transformer?

This could definitely be improved, but right now, the simplest is:

// Given [input], some input Asset:
transform.addOutput(input.id.addExtension(".foo"), input.read());

// or:
transform.addOutput(input.id.changeExtension(".foo"), input.read());

Depending on whether you want to replace or append to the extension.

Cheers!

- bob
Reply all
Reply to author
Forward
0 new messages