let disk_build = require('@ndcode/disk_build')
let emailjs = require('emailjs')
let fs = require('fs')
+let html_minifier = require('html-minifier')
let jst = require('@ndcode/jst')
let less = require('less/lib/less-node')
let path = require('path')
this.build_cache_json = new BuildCache()
this.build_cache_css_less = new BuildCache()
this.build_cache_css_min = new BuildCache()
+ this.build_cache_html_min = new BuildCache()
this.build_cache_js_min = new BuildCache()
this.build_cache_svg_min = new BuildCache()
this.build_cache_text = new BuildCache()
)
}
+Server.prototype.get_html_min = function(pathname) {
+ return /*await*/ this.build_cache_html_min.get(
+ pathname,
+ async result => {
+ result.value = fs_readFile(
+ await disk_build(
+ pathname,
+ async built_pathname => {
+ console.log('getting', pathname, 'as html_min')
+ let text = await fs_readFile(pathname, {encoding: 'utf-8'})
+ console.log('building', built_pathname)
+ return /*await*/ fs_writeFile(
+ built_pathname,
+ html_minifier.minify(text, {collapseWhitespace: true}),
+ {encoding: 'utf-8'}
+ )
+ }
+ )
+ )
+ }
+ )
+}
+
Server.prototype.get_js_min = function(pathname) {
return /*await*/ this.build_cache_js_min.get(
pathname,
SiteRoot.prototype.get_css_min = function(pathname) {
return /*await*/ this.server.get_css_min(this.root + pathname)
}
+SiteRoot.prototype.get_html_min = function(pathname) {
+ return /*await*/ this.server.get_html_min(this.root + pathname)
+}
SiteRoot.prototype.get_js_min = function(pathname) {
return /*await*/ this.server.get_js_min(this.root + pathname)
}