I make cite using Hugo and p5
On one page I have several skethes with p5 canvas.
So smth like this
sketch_1.js
import p5 from 'js/libs/p5.min.js';
import math from 'js/libs/math.js';
{
new p5(m);
...
}
sketch_2.js, sketch_3.js …
As you can see I import p5., math and I also import some local files.
After that I build page with shortcode like
include_sketch.html
...
{{ $js := resources.Get $abs_sketch_path | js.Build | resources.Minify }}
<script async src="{{ $js.RelPermalink }}"></script>
...
And everythings working BUT. js.Build just copy all content from p5 and other libs to sketch_N.js file.
So I have all sketches with average size like 1 Mb with copy of p5 and so on.
Is there a way to decompose files and import it like modules. So I would download only one p5.
I look docs from
Hugo js Build and read some forums but don’t find the solution
I expect file decomposition.
So browser download only one p5.js and only one math.js and so on
Роман Козак is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.