from flask_assets import Bundle, Environment, Filter

# fixes missing semicolon in last statement of jquery.pjax.js
class ConcatFilter(Filter):
    def concat(self, out, hunks, **kw):
        out.write(';'.join([h.data() for h, info in hunks]))

js = Bundle(
    'node_modules/jquery/dist/jquery.js',
    'node_modules/jquery-pjax/jquery.pjax.js',
    'node_modules/bootbox/bootbox.js',
    'node_modules/bootstrap/dist/js/bootstrap.min.js',
    'js/application.js',
    filters=(ConcatFilter, 'jsmin'),
    output='gen/packed.js'
)

css = Bundle(
    'node_modules/bootstrap/dist/css/bootstrap.css',
    'node_modules/font-awesome/css/font-awesome.css',
    'css/style.css',
    filters='cssmin',
    output='gen/packed.css'
)
assets = Environment()
assets.register('js_all', js)
assets.register('css_all', css)

from flask_assets import Bundle, Environment

js = Bundle(
    'node_modules/jquery/dist/jquery.js',
    'node_modules/jquery-pjax/jquery.pjax.js',
    'node_modules/bootbox/bootbox.js',
    'node_modules/bootstrap/dist/js/bootstrap.min.js',
    'js/application.js',
    filters='jsmin',
    output='gen/packed.js'
)
css = Bundle(
    'node_modules/bootstrap/dist/css/bootstrap.css',
    'node_modules/font-awesome/css/font-awesome.css',
    'css/style.css',
    filters='cssmin',
    output='gen/packed.css'
)
assets = Environment()
assets.register('js_all', js)
assets.register('css_all', css)

--- 
+++ 
@@ -1,4 +1,9 @@
-from flask_assets import Bundle, Environment
+from flask_assets import Bundle, Environment, Filter
+
+# fixes missing semicolon in last statement of jquery.pjax.js
+class ConcatFilter(Filter):
+    def concat(self, out, hunks, **kw):
+        out.write(';'.join([h.data() for h, info in hunks]))
 
 js = Bundle(
     'node_modules/jquery/dist/jquery.js',
@@ -6,9 +11,10 @@
     'node_modules/bootbox/bootbox.js',
     'node_modules/bootstrap/dist/js/bootstrap.min.js',
     'js/application.js',
-    filters='jsmin',
+    filters=(ConcatFilter, 'jsmin'),
     output='gen/packed.js'
 )
+
 css = Bundle(
     'node_modules/bootstrap/dist/css/bootstrap.css',
     'node_modules/font-awesome/css/font-awesome.css',
Add concat filter to fix issue with jquery-pjax

jquery-pjax makes use of IIFEs but does not terminate its last statement with a
semicolon, causing syntax errors after asset concatenation. See also:
https://github.com/miracle2k/webassets/issues/100#issuecomment-388461033
