diff --git a/frappe/hooks.py b/frappe/hooks.py index ba4176c3ed..42b1649bdf 100644 --- a/frappe/hooks.py +++ b/frappe/hooks.py @@ -37,8 +37,8 @@ app_include_js = [ "frappe/public/js/report.bundle.js", ] app_include_css = [ - "/assets/css/desk.min.css", - "/assets/css/report.min.css", + "frappe/public/scss/desk.bundle.scss", + "frappe/public/scss/report.bundle.scss", ] doctype_js = { diff --git a/frappe/utils/jinja.py b/frappe/utils/jinja.py index 8a80013887..e89427ac3f 100644 --- a/frappe/utils/jinja.py +++ b/frappe/utils/jinja.py @@ -24,7 +24,9 @@ def get_jenv(): 'inspect': inspect, 'web_blocks': web_blocks, 'web_block': web_block, - 'js_asset': js_asset + 'script': script, + 'style': style, + 'assets_url': assets_url }) frappe.local.jenv = jenv @@ -230,8 +232,23 @@ def web_blocks(blocks): return html -def js_asset(path): - import frappe - if not frappe.local.dev_server or True: - path = path.replace('frappe/public/', '/assets/frappe/build/') +def script(path): + path = assets_url(path) + if '/public/' in path: + path = path.replace('/public/', '/build/') return f'' + +def style(path): + path = assets_url(path) + if '/public/' in path: + path = path.replace('/public/', '/build/') + if path.endswith(('.scss', '.sass', '.less', '.styl')): + path = path.rsplit('.', 1)[0] + '.css' + return f'' + +def assets_url(path): + if not path.startswith('/'): + path = '/' + path + if not path.startswith('/assets'): + path = '/assets' + path + return path diff --git a/frappe/www/app.html b/frappe/www/app.html index 419d3ffe07..dd62a8bad0 100644 --- a/frappe/www/app.html +++ b/frappe/www/app.html @@ -21,7 +21,7 @@ {% for include in include_css -%} - + {{ style(include) }} {%- endfor -%} @@ -53,11 +53,9 @@ {% for include in include_js %} - {{ js_asset(include) }} + {{ script(include) }} {% endfor %} - {{ js_asset('frappe/public/js/test.bundle.js') }} - {% include "templates/includes/app_analytics/google_analytics.html" %} {% include "templates/includes/app_analytics/mixpanel_analytics.html" %}