Build assets (css, js) not being requested/served

Trying to learn custom frappe app development, and I’ve run into the following issue:

I’ve written some javascript on a custom Frappe application that is located in myapp/public/js/my_utils.js. I also wrote a build.json in myapp/public to bundle the code for minificiation.

I’ve confirmed the minified js file has been written to sites/assets after running

bench update --build

And my js code is in the minified folder. However, my min.js is never being server to the site that has the custom app installed. I wrote a form hook along the lines of

cur_frm.cscript.refresh = function(doc, dt, dn) {

    if(doc.__islocal){
       // do nothing
    }
    else{
        myapp.my_utils.foo(cur_frm);
    }
}

But because the file that defines myapp.my_utils file isn’t supplied, I get a “ReferenceError: myapp is not defined” in my firebug console.

What am I missing to trigger frappe to supply build assets?

There are 2 ways to do this:

  1. Add it to hooks as app_include_js (see example in frappe)
  2. Create a build.json file in your public folder to include it in any of the existing mins (frappe.min.js)

or… may i add a third option?
3. create a build.json file in public folder and include it on your own filename.min.js or other name that you like and then add a hook as app_include_js, like this:

build.son file:
    {
    	"css/jasper_erpnext_report.css": [
    		"public/css/callouts.css"
        ],
    	"js/jasper_erpnext_report.js": [
    		"public/js/jasper_erpnext_report.js"
    	]
    }


 hooks.py file:
     app_include_js = ["/assets/jasper_erpnext_report/js/jasper_erpnext_report.js"] if you like to refresh and don't want make frappe --build every time you change the file.

or app_include_js = ["/assets/js/jasper_erpnext_report.js"] if you want to do frappe --build every time!

then do bench frappe --build

1 Like

I was missing the entry in hooks.py. Luis’ suggestion is what I was attempting.

Thanks for the help