Discussion:
[dart-misc] Another question about package:build on .html files
Ryan Gonzalez
2018-03-11 22:07:29 UTC
Permalink
A while back I asked something similar to this, but I have a different
question this time.

One of my transformers is an HTML preprocessor. Now, you can probably
already see the problem here. Since you can only generate new files,
not overwrite them, I can't rewrite the input HTML file. However,
paths with .html are (obviously) significant: rewriting index.html to
index.g.html just isn't ideal.

My question is: how should I handle this?
--
Ryan (ライアン)
Yoko Shimomura, ryo (supercell/EGOIST), Hiroyuki Sawano >> everyone else
https://refi64.com/
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Matan Lurey
2018-03-11 22:13:41 UTC
Permalink
Hi Ryan!

You're right that builds cannot overwrite or modify existing files. We've
captured some *Dart* workarounds here:
https://github.com/dart-lang/build/blob/master/docs/transforming_code.md

Would love a bug (or a PR!) pushing us to document how to handle non-Dart
assets. For your particular example, I've seen the following:

your_pkg/
web/
index.template.html

Where you write the final result as index.html (from index.template.html)

You could also create a separate template/ folder, i.e.:

your_pkg/
web/
template/
index.html

... where it is copied into web/ with changes made. Hope that helps!

~ Matan
Post by Ryan Gonzalez
A while back I asked something similar to this, but I have a different
question this time.
One of my transformers is an HTML preprocessor. Now, you can probably
already see the problem here. Since you can only generate new files,
not overwrite them, I can't rewrite the input HTML file. However,
paths with .html are (obviously) significant: rewriting index.html to
index.g.html just isn't ideal.
My question is: how should I handle this?
--
Ryan (ラむアン)
Yoko Shimomura, ryo (supercell/EGOIST), Hiroyuki Sawano >> everyone else
https://refi64.com/
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Ryan Gonzalez
2018-03-11 22:25:10 UTC
Permalink
Hmm...well, I'm doing this for my personal website <https://refi64.com/>,
and I'm probably going to be running the preprocessor on *every post*, so
renaming everything to .template.html wouldn't work...

Based on this, since package:build seems more flexible (outside of this)
than Pub, could I just output the files to a directory *other* than 'web'?
E.g., build/built-web or similar.
Post by Matan Lurey
Hi Ryan!
You're right that builds cannot overwrite or modify existing files. We've
https://github.com/dart-lang/build/blob/master/docs/transforming_code.md
Would love a bug (or a PR!) pushing us to document how to handle non-Dart
your_pkg/
web/
index.template.html
Where you write the final result as index.html (from index.template.html)
your_pkg/
web/
template/
index.html
... where it is copied into web/ with changes made. Hope that helps!
~ Matan
Post by Ryan Gonzalez
A while back I asked something similar to this, but I have a different
question this time.
One of my transformers is an HTML preprocessor. Now, you can probably
already see the problem here. Since you can only generate new files,
not overwrite them, I can't rewrite the input HTML file. However,
paths with .html are (obviously) significant: rewriting index.html to
index.g.html just isn't ideal.
My question is: how should I handle this?
--
Ryan (ラむアン)
Yoko Shimomura, ryo (supercell/EGOIST), Hiroyuki Sawano >> everyone else
https://refi64.com/
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
Ryan (ラむアン)
Yoko Shimomura, ryo (supercell/EGOIST), Hiroyuki Sawano >> everyone else
https://refi64.com/
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Matan Lurey
2018-03-11 22:31:37 UTC
Permalink
Sure, you could totally do that. That was sort of my second example, i.e.
write the following:

your_site/
lib/
web_template/

and have it output everything in web_template/ ==> web/

You probably want to reserve "web" for the actual (built) site assets.
Build runner merges a combination of static and built assets together. So
for example, if you have:

your_site/
web/
favicon.png
web_template/
index.html

Both "favicon.png" and "index.html" would be in your final (built) web
directory. Does that help?
Post by Ryan Gonzalez
Hmm...well, I'm doing this for my personal website <https://refi64.com/>,
and I'm probably going to be running the preprocessor on *every post*, so
renaming everything to .template.html wouldn't work...
Based on this, since package:build seems more flexible (outside of this)
than Pub, could I just output the files to a directory *other* than
'web'? E.g., build/built-web or similar.
Post by Matan Lurey
Hi Ryan!
You're right that builds cannot overwrite or modify existing files. We've
https://github.com/dart-lang/build/blob/master/docs/transforming_code.md
Would love a bug (or a PR!) pushing us to document how to handle non-Dart
your_pkg/
web/
index.template.html
Where you write the final result as index.html (from index.template.html)
your_pkg/
web/
template/
index.html
... where it is copied into web/ with changes made. Hope that helps!
~ Matan
Post by Ryan Gonzalez
A while back I asked something similar to this, but I have a different
question this time.
One of my transformers is an HTML preprocessor. Now, you can probably
already see the problem here. Since you can only generate new files,
not overwrite them, I can't rewrite the input HTML file. However,
paths with .html are (obviously) significant: rewriting index.html to
index.g.html just isn't ideal.
My question is: how should I handle this?
--
Ryan (ラむアン)
Yoko Shimomura, ryo (supercell/EGOIST), Hiroyuki Sawano >> everyone else
https://refi64.com/
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
Ryan (ラむアン)
Yoko Shimomura, ryo (supercell/EGOIST), Hiroyuki Sawano >> everyone else
https://refi64.com/
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Ryan Gonzalez
2018-03-11 23:13:02 UTC
Permalink
Yup...thanks!
Post by Matan Lurey
Sure, you could totally do that. That was sort of my second example, i.e.
your_site/
lib/
web_template/
and have it output everything in web_template/ ==> web/
You probably want to reserve "web" for the actual (built) site assets.
Build runner merges a combination of static and built assets together. So
your_site/
web/
favicon.png
web_template/
index.html
Both "favicon.png" and "index.html" would be in your final (built) web
directory. Does that help?
Post by Ryan Gonzalez
Hmm...well, I'm doing this for my personal website <https://refi64.com/>,
and I'm probably going to be running the preprocessor on *every post*,
so renaming everything to .template.html wouldn't work...
Based on this, since package:build seems more flexible (outside of this)
than Pub, could I just output the files to a directory *other* than
'web'? E.g., build/built-web or similar.
Post by Matan Lurey
Hi Ryan!
You're right that builds cannot overwrite or modify existing files.
https://github.com/dart-lang/build/blob/master/docs/transforming_code.md
Would love a bug (or a PR!) pushing us to document how to handle
your_pkg/
web/
index.template.html
Where you write the final result as index.html (from index.template.html)
your_pkg/
web/
template/
index.html
... where it is copied into web/ with changes made. Hope that helps!
~ Matan
Post by Ryan Gonzalez
A while back I asked something similar to this, but I have a different
question this time.
One of my transformers is an HTML preprocessor. Now, you can probably
already see the problem here. Since you can only generate new files,
not overwrite them, I can't rewrite the input HTML file. However,
paths with .html are (obviously) significant: rewriting index.html to
index.g.html just isn't ideal.
My question is: how should I handle this?
--
Ryan (ラむアン)
Yoko Shimomura, ryo (supercell/EGOIST), Hiroyuki Sawano >> everyone else
https://refi64.com/
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send
--
Ryan (ラむアン)
Yoko Shimomura, ryo (supercell/EGOIST), Hiroyuki Sawano >> everyone else
https://refi64.com/
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
Ryan (ラむアン)
Yoko Shimomura, ryo (supercell/EGOIST), Hiroyuki Sawano >> everyone else
https://refi64.com/
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Continue reading on narkive:
Loading...