Small adjustments in webasset filters
* Add comment with source file to JsDelimiterBundler and
JsPluginDelimiterBundler
* Include source file name in JsPluginDelimiterBundler catch
block and use log.error instead of console.error
This commit is contained in:
parent
dc53942015
commit
9837f67140
2 changed files with 11 additions and 3 deletions
|
|
@ -1235,7 +1235,8 @@ class Server(object):
|
|||
less_plugins = list(dynamic_plugin_assets["external"]["less"])
|
||||
|
||||
# a couple of custom filters
|
||||
from octoprint.server.util.webassets import LessImportRewrite, JsDelimiterBundler, JsPluginDelimiterBundler, SourceMapRewrite, SourceMapRemove
|
||||
from octoprint.server.util.webassets import LessImportRewrite, JsDelimiterBundler, JsPluginDelimiterBundler, \
|
||||
SourceMapRewrite, SourceMapRemove
|
||||
from webassets.filter import register_filter
|
||||
|
||||
register_filter(LessImportRewrite)
|
||||
|
|
@ -1246,7 +1247,7 @@ class Server(object):
|
|||
|
||||
# JS
|
||||
js_filters = ["sourcemap_remove", "js_delimiter_bundler"]
|
||||
js_plugin_filters = js_filters + ["js_plugin_delimiter_bundler"]
|
||||
js_plugin_filters = ["sourcemap_remove", "js_plugin_delimiter_bundler"]
|
||||
|
||||
js_libs_bundle = Bundle(*js_libs, output="webassets/packed_libs.js", filters=",".join(js_filters))
|
||||
|
||||
|
|
|
|||
|
|
@ -96,14 +96,21 @@ class JsDelimiterBundler(Filter):
|
|||
options = {}
|
||||
|
||||
def input(self, _in, out, **kwargs):
|
||||
source = kwargs.get("source", "n/a")
|
||||
|
||||
out.write("// source: " + source + "\n")
|
||||
out.write(_in.read())
|
||||
out.write("\n;\n")
|
||||
|
||||
|
||||
class JsPluginDelimiterBundler(Filter):
|
||||
name = "js_plugin_delimiter_bundler"
|
||||
options = {}
|
||||
|
||||
def input(self, _in, out, **kwargs):
|
||||
source = kwargs.get("source", "n/a")
|
||||
|
||||
out.write("// source: " + source + "\n")
|
||||
out.write("(function () {\n try {\n ")
|
||||
out.write(_in.read().replace('\n', '\n '))
|
||||
out.write("\n } catch (error) {\n console.error(error);\n }\n})();\n")
|
||||
out.write("\n } catch (error) {\n log.error(\"Error in bundled asset " + source + ":\", (error.stack || error));\n }\n})();\n")
|
||||
|
|
|
|||
Loading…
Reference in a new issue