in lib/ES/Util.pm [719:778]
sub build_web_resources {
#===================================
my ( $dest ) = @_;
my $parcel_out = dir('/tmp/parcel');
my $compiled_js = $parcel_out->file('docs_js/index-v1.js');
my $compiled_css = $parcel_out->file('styles-v1.css');
unless ( -e $compiled_js && -e $compiled_css ) {
# We write the compiled js and css to /tmp so we can use them on
# subsequent runs in the same container. This doesn't come up when you
# build docs either with --doc or --all *but* it comes up all the time
# when you run the integration tests and saves about 1.5 seconds on
# every docs build.
say "Compiling web resources";
run '/node_modules/parcel/bin/cli.js', 'build',
'--public-url', '/guide/static/',
'--experimental-scope-hoisting', '--no-source-maps',
'-d', $parcel_out,
'resources/web/docs_js/index-v1.js', 'resources/web/styles-v1.pcss';
die "Parcel didn't make $compiled_js" unless -e $compiled_js;
die "Parcel didn't make $compiled_css" unless -e $compiled_css;
}
my $static_dir = $dest->subdir( 'raw' )->subdir( 'static' );
$static_dir->mkpath;
my $js = $static_dir->file( 'docs-v1.js' );
my $css = $static_dir->file( 'styles-v1.css' );
my $js_licenses = file( 'resources/web/docs.js.licenses' );
my $css_licenses = file( 'resources/web/styles.css.licenses' );
$js->spew(
iomode => '>:utf8',
$js_licenses->slurp( iomode => '<:encoding(UTF-8)' ) . $compiled_js->slurp( iomode => '<:encoding(UTF-8)' )
);
$css->spew(
iomode => '>:utf8',
$css_licenses->slurp( iomode => '<:encoding(UTF-8)' ) . $compiled_css->slurp( iomode => '<:encoding(UTF-8)' )
);
for ( $parcel_out->children ) {
next unless /.+\.woff2?/;
rcopy( $_, $static_dir );
}
rcopy( '/node_modules/jquery/dist/jquery.min.js', $static_dir->file( 'jquery.js' ) );
# The public site can't ready anything from the raw directory so we have to
# copy the static files to html as well.
my $templated_dir = $dest->subdir( 'html' )->subdir( 'static' );
$templated_dir->mkpath;
rcopy( $static_dir, $templated_dir );
# Copy the template to the root of the repo so we can apply it on the fly.
# NOTE: We only apply it on the fly for preview right now.
for ( qw(template air_gapped_template) ) {
my $template_source = file("resources/web/$_.html");
my $template = $dest->file("$_.html");
rcopy( $template_source, $template );
}
}