def static(path, input): '''Compile and collect static files''' log = logging.getLogger('webassets') log.addHandler(logging.StreamHandler()) log.setLevel(logging.DEBUG) if exists(path): print('"{0}" directory already exists and will be erased'.format(path)) if input and not prompt_bool('Are you sure'): exit(-1) cmdenv = CommandLineEnvironment(assets, log) # cmdenv.clean() cmdenv.build(production=True) print('Deleting static directory {0}'.format(path)) shutil.rmtree(path) print('Copying assets into "{0}"'.format(path)) shutil.copytree(assets.directory, path) for prefix, source in manager.app.config['STATIC_DIRS']: print('Copying %s to %s', source, prefix) destination_path = join(path, prefix) if not exists(destination_path): makedirs(destination_path) for filename in iglob(join(source, '*')): print(filename) if isdir(filename): continue shutil.copy(filename, destination_path) # shutil.copy(static_dir, path) print('Done')
def build(self): logger = getLogger('webassets') logger.addHandler(StreamHandler()) logger.setLevel(DEBUG) cli_environment = CommandLineEnvironment(self.env, logger) cli_environment.invoke("build", args={})
def js(): log = logging.getLogger('webassets') log.addHandler(logging.StreamHandler()) log.setLevel(logging.WARNING) cmdenv = CommandLineEnvironment(assets_env, log) cmdenv.build()
def main(): log = logging.getLogger('webassets') log.addHandler(logging.StreamHandler()) log.setLevel(logging.DEBUG) call(["coffee", "-c", "src/tambur.coffee"]) call(["coffee", "-c", "src/tambur_publisher.coffee"]) env = Environment('.', '/static') jsonjs = Bundle( 'deps/json2.js', filters='yui_js', output='out/json2.min.js') sockjs = Bundle( 'deps/web_socket.js', filters='yui_js', output='out/web_socket.min.js') tamburjs = Bundle( 'deps/swfobject.js', 'src/tambur.js', output='out/tambur.js') tamburminjs = Bundle( 'deps/swfobject.js', 'src/tambur.js', filters='yui_js', output='out/tambur.min.js') publishjs = Bundle( 'deps/sha1.js', 'deps/oauth.js', 'src/tambur_publisher.js', output='out/tambur_pub.js') publishminjs = Bundle( 'deps/sha1.js', 'deps/oauth.js', 'src/tambur_publisher.js', filters='yui_js', output='out/tambur_pub.min.js') env.register('tambur.js', tamburjs) env.register('tambur.min.js', tamburminjs) env.register('tambur_pub.js', publishjs) env.register('tambur_pub.min.js', publishminjs) env.register('json2.js', jsonjs) env.register('web_socket.js', sockjs) cmdenv = CommandLineEnvironment(env, log) cmdenv.build()
def _init_webassets(debug=False): assets_env = Environment(directory=SITE_ASSET_DIR, url=SITE_ASSET_URL_PREFIX, cache=WEBASSETS_CACHE_DIR, load_path=[SITE_ASSET_SRC_DIR]) assets_env.debug = debug js = Bundle('js/*.js', filters='uglifyjs', output='js/app.js') css = Bundle('sass/*.scss', filters='scss,cssmin', output='css/app.css') assets_env.register('app_js', js) assets_env.register('app_css', css) cmd = CommandLineEnvironment(assets_env, log) p = Process(target=lambda: cmd.watch()) def signal_handler(sig, frame): try: p.terminate() except Exception: pass sys.exit(0) signal.signal(signal.SIGINT, signal_handler) p.start() return assets_env
def build_assets(): log = logging.getLogger('webassets') log.addHandler(logging.StreamHandler()) log.setLevel(logging.DEBUG) cmdenv = CommandLineEnvironment(assets_env, log) cmdenv.build()
def run(self): from webassets import Bundle from webassets import Environment from webassets.script import CommandLineEnvironment css = Bundle('curious/src/css/app.css', output='curious/dist/curious.css') js = Bundle('curious/src/js/*.js', output='curious/dist/curious.js') jsm = Bundle('curious/src/js/*.js', filters='jsmin', output='curious/dist/curious.min.js') jst = Bundle('curious/src/html/*.html', filters='jst', output='curious/dist/curious_jst.js') assets_env = Environment('./curious/static') assets_env.cache = self.cache_dir assets_env.register('css', css) assets_env.register('js', js) assets_env.register('jsmin', jsm) assets_env.register('jst', jst) log = logging.getLogger('webassets') log.addHandler(logging.StreamHandler()) log.setLevel(logging.DEBUG) cmdenv = CommandLineEnvironment(assets_env, log) cmdenv.build()
def handle(self, *args, **options): valid_commands = CommandLineEnvironment.Commands if len(args) > 1: raise CommandError('Invalid number of subcommands passed: %s' % ", ".join(args)) elif len(args) == 0: raise CommandError('You need to specify a subcommand: %s' % ', '.join(valid_commands)) # Create log log = logging.getLogger('django-assets') log.setLevel({0: logging.WARNING, 1: logging.INFO, 2: logging.DEBUG}[int(options.get('verbosity', 1))]) log.addHandler(logging.StreamHandler()) # If the user requested it, search for bundles defined in templates if options.get('parse_templates'): log.info('Searching templates...') # Note that we exclude container bundles. By their very nature, # they are guaranteed to have been created by solely referencing # other bundles which are already registered. get_env().add(*[b for b in self.load_from_templates() if not b.is_container]) if len(get_env()) == 0: raise CommandError('No asset bundles were found. ' 'If you are defining assets directly within your ' 'templates, you want to use the --parse-templates ' 'option.') # Execute the requested subcommand cmd = CommandLineEnvironment(get_env(), log) try: cmd.invoke(args[0]) except AssetCommandError, e: raise CommandError(e)
def _build_webassets(self): # Set up a logger log = logging.getLogger('webassets') log.addHandler(logging.StreamHandler()) log.setLevel(logging.DEBUG) cmdenv = CommandLineEnvironment(self.webassets_env, log) cmdenv.build()
def action(rebuild=False, watch=False, check=False, clean=False, quiet=('q', False), verbose=('v', False)): if len(filter(bool, [rebuild, watch, clean, check])) != 1: print "Error: exactly one of --rebuild, --watch, --check or --clean must be given" return 1 if rebuild: command = 'rebuild' elif watch: command = 'watch' elif clean: command = 'clean' elif check: command = 'check' log.setLevel(logging.DEBUG if verbose else ( logging.WARNING if quiet else logging.INFO)) cmdenv = CommandLineEnvironment(environment, log) if loaders: log.info('Finding bundles...') for loader in loaders: environment.add( *[b for b in loader.load_bundles() if not b.is_container]) cmdenv.invoke(command)
def main(): log = logging.getLogger('webassets') log.addHandler(logging.StreamHandler()) log.setLevel(logging.DEBUG) call(["coffee", "-c", "src/tambur.coffee"]) call(["coffee", "-c", "src/tambur_publisher.coffee"]) env = Environment('.', '/static') tamburjs = Bundle( 'deps/sockjs-0.3.js', 'src/tambur.js', output='out/tambur.js') tamburminjs = Bundle( 'deps/sockjs-0.3.js', 'src/tambur.js', filters='yui_js', output='out/tambur.min.js') publishjs = Bundle( 'deps/sha1.js', 'deps/oauth.js', 'src/tambur_publisher.js', output='out/tambur_pub.js') publishminjs = Bundle( 'deps/sha1.js', 'deps/oauth.js', 'src/tambur_publisher.js', filters='yui_js', output='out/tambur_pub.min.js') env.register('tambur.js', tamburjs) env.register('tambur.min.js', tamburminjs) env.register('tambur_pub.js', publishjs) env.register('tambur_pub.min.js', publishminjs) cmdenv = CommandLineEnvironment(env, log) cmdenv.build()
def build_assets(app): from webassets.script import CommandLineEnvironment assets_env = app.jinja_env.assets_environment log = logging.getLogger('webassets') log.addHandler(logging.StreamHandler()) log.setLevel(logging.DEBUG) cmdenv = CommandLineEnvironment(assets_env, log) cmdenv.build()
def handle(self, app, **kwargs): assets = Environment(app) assets.url = app.static_url_path# = os.path.join(_appdir, 'static') assets.register('all_css', app.bundles['all_css_min']) assets.register('all_js', app.bundles['all_js_min']) log = logging.getLogger('webassets') log.addHandler(logging.StreamHandler()) log.setLevel(logging.DEBUG) cmdenv = CommandLineEnvironment(assets, log) cmdenv.invoke('build', kwargs)
def run(self): assets_env = get_webassets_env({ 'debug': False, 'static_files_dir': STATIC, }) cmdenv = CommandLineEnvironment(assets_env, log) cmdenv.build() self.copy_assets()
def clear_css_cache(): import logging from webassets.script import CommandLineEnvironment # Setup a logger log = logging.getLogger('webassets') log.addHandler(logging.StreamHandler()) log.setLevel(logging.DEBUG) cmdenv = CommandLineEnvironment(assets, log) cmdenv.clean()
def rebuild_assets(config): config = config.copy() config['assets.debug'] = True assets = make_assets(config) assets_dir = assets.env.directory # Remove existing assets for name, bundle in assets.env._named_bundles.items(): path = os.path.join(assets_dir, bundle.output) % {'version': '*'} for p in glob.iglob(path): os.unlink(p) cmdenv = CommandLineEnvironment(assets.env, logging.getLogger('assets')) cmdenv.invoke('build', {})
def build_assets(mod): from webassets.script import CommandLineEnvironment module = import_module(mod, True) assets_env = module.app.jinja_env.assets_environment log = logging.getLogger('webassets') log.addHandler(logging.StreamHandler()) log.setLevel(logging.DEBUG) cmdenv = CommandLineEnvironment(assets_env, log) cmdenv.build()
def gen_static(): # Setup a logger log = logging.getLogger('webassets') log.addHandler(logging.StreamHandler()) log.setLevel(logging.DEBUG) assets_env = Environment() assets_env.directory = "static/" assets_env.debug = True assets_env.register(bundles) cmdenv = CommandLineEnvironment(assets_env, log) # This would also work cmdenv.build()
def _buildassets(app): from webassets.script import CommandLineEnvironment module = get_app_serve_module(app) assets_env = module.app.jinja_env.assets_environment log = logging.getLogger('webassets') log.addHandler(logging.StreamHandler()) log.setLevel(logging.DEBUG) cmdenv = CommandLineEnvironment(assets_env, log) cmdenv.build()
def scss_compile(static_path): webassets = Environment() webassets.directory = static_path webassets.url = static_path webassets.register('css_all', css_all) #webassets.manifest = 'cache' if not app.debug else False webassets.manifest = False webassets.cache = False webassets.debug = False log = logging.getLogger('webassets') log.addHandler(logging.StreamHandler()) log.setLevel(logging.DEBUG) cmdenv = CommandLineEnvironment(webassets, log) # This would also work cmdenv.build()
def test_watch_config_file(self): """The watch command has an eye on the config file. This is an extension to the base watch command.""" try: import yaml except ImportError: raise SkipTest() self.cmd_env = CommandLineEnvironment(self.env, logging) self.cmd_env.commands['watch'] = \ GenericArgparseImplementation.WatchCommand( self.cmd_env, argparse.Namespace(config=self.path('config.yml'))) self.create_files({'in': 'foo'}) template = """ directory: . bundles: foo: contents: - in output: %s """ self.create_files({'config.yml': template % 'outA'}) with self: time.sleep(0.1) # Change the config file; this change is detected; we update # the timestamp explicitly or we might not have enough precision self.create_files({'config.yml': template % 'outB'}) self.setmtime('config.yml', mod=100) time.sleep(0.2) # The second output file has been built assert self.get('outB') == 'foo'
def _webassets_cmd(cmd): """Helper to run a webassets command.""" from webassets.script import CommandLineEnvironment logger = logging.getLogger('webassets') logger.addHandler(logging.StreamHandler()) logger.setLevel(logging.DEBUG) cmdenv = CommandLineEnvironment( current_app.jinja_env.assets_environment, logger) getattr(cmdenv, cmd)()
def static(path, input): '''Compile and collect static files''' log = logging.getLogger('webassets') log.addHandler(logging.StreamHandler()) log.setLevel(logging.DEBUG) cmdenv = CommandLineEnvironment(assets, log) cmdenv.build() if exists(path): print('"{0}" directory already exists and will be erased'.format(path)) if input and not prompt_bool('Are you sure'): exit(-1) shutil.rmtree(path) print('Copying assets into "{0}"'.format(path)) shutil.copytree(assets.directory, path) print('Done')
def static(path, no_input): '''Compile and collect static files into path''' log = logging.getLogger('webassets') log.addHandler(logging.StreamHandler()) log.setLevel(logging.DEBUG) cmdenv = CommandLineEnvironment(assets, log) cmdenv.build() if exists(path): warning('{0} directory already exists and will be {1}', white(path), white('erased')) if not no_input and not click.confirm('Are you sure'): exit_with_error() shutil.rmtree(path) echo('Copying assets into {0}', white(path)) shutil.copytree(assets.directory, path) success('Done')
def init_app(app): """ Initilize assets. :param app: """ if app.debug: webassets = Environment(app) webassets.url = app.static_url_path webassets.register('css_all', css_all) webassets.manifest = False webassets.cache = False webassets.debug = False webassets.cache = not app.debug webassets.debug = app.debug log = logging.getLogger('webassets') log.addHandler(logging.StreamHandler()) log.setLevel(logging.DEBUG) cmdenv = CommandLineEnvironment(webassets, log) cmdenv.build()
def build(silent=False): """ Build the static Files""" env = current_app.jinja_env.assets_environment cmd = CommandLineEnvironment(env, log) directory = env.get_directory() mybuild = BuildCommand(cmd) mybuild(directory=directory)
def bundle(**kwargs): """ Webassets bundle management. usage: blueberrypy bundle [options] Before you can use this command to bundle up your Web assets, you should have created either a project skeleton using the 'create' command or provided a configuration directory using the global option -c --config_dir. options: -h, --help show this help message and exit -C ENV_VAR_NAME, --env-var ENV_VAR_NAME add the given config from environment variable name [default: BLUEBERRYPY_CONFIG] -b, --build build the asset bundles -w, --watch automatically rebuild the asset bundles upon changes in the static directory -c, --clean delete the generated asset bundles """ config = BlueberryPyConfiguration(config_dir=kwargs.get('config_dir'), env_var_name=kwargs.get('env_var')) assets_env = config.webassets_env if not assets_env: raise BlueberryPyNotConfiguredError("Webassets configuration not found.") from webassets.script import CommandLineEnvironment assets_cli = CommandLineEnvironment(assets_env, logger) if kwargs.get("build"): try: assets_cli.build() except AttributeError: assets_cli.rebuild() elif kwargs.get("watch"): assets_cli.watch() elif kwargs.get("clean"): assets_cli.clean()
def test_watch_with_fixed_env_and_no_config(self): """[Regression[ The custom 'watch' command does not break if the CLI is initialized via fixed environment, instead of reading one from a configuration file. """ self.cmd_env = CommandLineEnvironment(self.env, logging) self.cmd_env.commands['watch'] = \ GenericArgparseImplementation.WatchCommand( self.cmd_env, argparse.Namespace()) with self: time.sleep(0.1)
class TestCLI(object): def setup(self): self.assets_env = Environment("", "") self.cmd_env = CommandLineEnvironment(self.assets_env, logging) def test_rebuild_container_bundles(self): """Test the rebuild command can deal with container bundles. """ a = MockBundle(output="a") b1 = MockBundle(output="b1") b2 = MockBundle(output="b2") b = MockBundle(b1, b2) self.assets_env.add(a, b) self.cmd_env.rebuild() assert a.build_called assert not b.build_called assert b1.build_called assert b2.build_called
class TestCLI(object): def setup(self): self.assets_env = Environment('', '') self.cmd_env = CommandLineEnvironment(self.assets_env, logging) def test_rebuild_container_bundles(self): """Test the rebuild command can deal with container bundles. """ a = MockBundle(output='a') b1 = MockBundle(output='b1') b2 = MockBundle(output='b2') b = MockBundle(b1, b2) self.assets_env.add(a, b) self.cmd_env.rebuild() assert a.build_called assert not b.build_called assert b1.build_called assert b2.build_called
def build(): '''Compile static files''' log = logging.getLogger('webassets') log.addHandler(logging.StreamHandler()) log.setLevel(logging.DEBUG) # Override some local config current_app.config['DEBUG'] = False current_app.config['ASSETS_DEBUG'] = False current_app.config['REQUIREJS_RUN_IN_DEBUG'] = True cmdenv = CommandLineEnvironment(assets, log) cmdenv.build(production=True) print('Performing require.js optimization') buildfile = join(assets.directory, 'js', 'app.build.js') # bust = 'pragmas.bust={0}'.format(time.time()) params = ['r.js', '-o', buildfile] subprocess.call(params) print('Done')
def build(): '''Compile static files''' log = logging.getLogger('webassets') log.addHandler(logging.StreamHandler()) log.setLevel(logging.DEBUG) # Override some local config current_app.config['DEBUG'] = False current_app.config['ASSETS_DEBUG'] = False current_app.config['REQUIREJS_RUN_IN_DEBUG'] = True cmdenv = CommandLineEnvironment(theme.assets, log) cmdenv.build(production=True) print('Performing require.js optimization') buildfile = join(theme.assets.directory, 'js', 'app.build.js') # bust = 'pragmas.bust={0}'.format(time.time()) params = ['r.js', '-o', buildfile] subprocess.call(params) print('Done')
def main(): log = logging.getLogger('webassets') log.addHandler(logging.StreamHandler()) log.setLevel(logging.DEBUG) env = Environment('.', '/static') jsonjs = Bundle( 'deps/json2.js', filters='yui_js', output='out/json2.min.js') sockjs = Bundle( 'deps/web_socket.js', filters='yui_js', output='out/web_socket.min.js') tamburjs = Bundle( 'deps/swfobject.js', 'src/tambur_comet_fallback.js', 'src/tambur_connection.js', 'src/tambur_logger.js', 'src/tambur_utils.js', 'src/tambur_stream.js', output='out/tambur.js') tamburminjs = Bundle( 'deps/swfobject.js', 'src/tambur_comet_fallback.js', 'src/tambur_connection.js', 'src/tambur_logger.js', 'src/tambur_utils.js', 'src/tambur_stream.js', filters='yui_js', output='out/tambur.min.js') publishjs = Bundle( 'deps/sha1.js', 'deps/oauth.js', 'src/tambur_publisher.js', output='out/tambur_pub.js') publishminjs = Bundle( 'deps/sha1.js', 'deps/oauth.js', 'src/tambur_publisher.js', filters='yui_js', output='out/tambur_pub.min.js') env.register('tambur.js', tamburjs) env.register('tambur.min.js', tamburminjs) env.register('tambur_pub.js', publishjs) env.register('tambur_pub.min.js', publishminjs) env.register('json2.js', jsonjs) env.register('web_socket.js', sockjs) cmdenv = CommandLineEnvironment(env, log) cmdenv.build()
def _init_webassets(debug=False, generate=False): assets_env = Environment(directory=SITE_ASSET_DIR, url=SITE_ASSET_URL_PREFIX, cache=WEBASSETS_CACHE_DIR, load_path=[SITE_ASSET_SRC_DIR]) assets_env.debug = debug js = Bundle('js/*.js', filters='uglifyjs', output='js/app.js') css = Bundle('sass/*.scss', filters='scss,cssmin', output='css/app.css') assets_env.register('app_js', js) assets_env.register('app_css', css) cmd = CommandLineEnvironment(assets_env, log) if generate: cmd.build() return assets_env Process(target=lambda: cmd.watch()).start() return assets_env
def action(rebuild=False, watch=False, clean=False, quiet=('q', False), verbose=('v', False)): if len(filter(bool, [rebuild, watch, clean])) != 1: print "Error: exactly one of --rebuild, --watch or --clean must be given" return 1 if rebuild: command = 'rebuild' elif watch: command = 'watch' elif clean: command = 'clean' log.setLevel(logging.DEBUG if verbose else (logging.WARNING if quiet else logging.INFO)) cmdenv = CommandLineEnvironment(environment, log) if loaders: log.info('Finding bundles...') for loader in loaders: environment.add(*[b for b in loader.load_bundles() if not b.is_container]) cmdenv.invoke(command)
def run(self): from webassets import Bundle from webassets import Environment from webassets.script import CommandLineEnvironment css = Bundle('curious/src/css/app.css', output='curious/dist/curious.css') js = Bundle('curious/src/js/*.js', output='curious/dist/curious.js') jsmin = Bundle('curious/src/js/*.js', filters='jsmin', output='curious/dist/curious.min.js') jst = Bundle('curious/src/html/*.html', filters='jst', output='curious/dist/curious_jst.js') assets_env = Environment('./curious/static') assets_env.cache = self.cache_dir assets_env.register('css', css) assets_env.register('js', js) assets_env.register('jsmin', jsmin) assets_env.register('jst', jst) log = logging.getLogger('webassets') log.addHandler(logging.StreamHandler()) log.setLevel(logging.DEBUG) cmdenv = CommandLineEnvironment(assets_env, log) cmdenv.build()
def bundle(**kwargs): """ Webassets bundle management. usage: blueberrypy bundle [options] Before you can use this command to bundle up your Web assets, you should have created either a project skeleton using the 'create' command or provided a configuration directory using the global option -c --config_dir. options: -h, --help show this help message and exit -b, --build build the asset bundles -w, --watch automatically rebuild the asset bundles upon changes in the static directory -c, --clean delete the generated asset bundles """ config = BlueberryPyConfiguration(config_dir=kwargs.get("config_dir")) assets_env = config.webassets_env if not assets_env: raise BlueberryPyNotConfiguredError("Webassets configuration not found.") from webassets.script import CommandLineEnvironment assets_cli = CommandLineEnvironment(assets_env, logger) if kwargs.get("build"): try: assets_cli.build() except AttributeError: assets_cli.rebuild() elif kwargs.get("watch"): assets_cli.watch() elif kwargs.get("clean"): assets_cli.clean()
def build(debug=True, cache=True): env = _setup_env(debug, cache) log = _load_logger() cmdenv = CommandLineEnvironment(env, log) cmdenv.rebuild()
def assets_(): CommandLineEnvironment(assets, getLogger('flask')).build()
'js/app.js', filters='uglifyjs', output='js/electris-footer.min.js') css = Bundle('bootstrap/css/bootstrap.min.css', 'bootstrap/css/bootstrap-responsive.min.css', 'css/template.css', 'css/app.css', 'css/sponsorship.css', filters='yui_css', output='css/electris.min.css') static.register('js_header', header_js) static.register('js_footer', footer_js) static.register('css', css) header_js.urls() footer_js.urls() css.urls() import logging from webassets.script import CommandLineEnvironment # Setup a logger log = logging.getLogger('webassets') log.addHandler(logging.StreamHandler()) log.setLevel(logging.DEBUG) cmdenv = CommandLineEnvironment(static, log) cmdenv.watch()
def setup(self): self.assets_env = Environment('', '') self.cmd_env = CommandLineEnvironment(self.assets_env, logging)
def build_assets(): from webassets.script import CommandLineEnvironment CommandLineEnvironment(env, assets_logger).build()
def compile(): """Compile assets.""" log = logging.getLogger(__name__) cmd = CommandLineEnvironment(get_env(), log) cmd.build()
def watch(debug=False, cache=False): env = _setup_env(debug, cache) log = _load_logger() cmdenv = CommandLineEnvironment(env, log) cmdenv.watch()
def build_assets(): CommandLineEnvironment(assets_env, logger).build()
import logging from os import makedirs, path from webassets.script import CommandLineEnvironment from cunhajacaiu import assets from cunhajacaiu.settings import STATIC_PATH for dir in ('css', 'js'): makedirs(path.join(path.abspath(STATIC_PATH), dir), exist_ok=True) log = logging.getLogger('webassets') log.addHandler(logging.StreamHandler()) log.setLevel(logging.DEBUG) cli = CommandLineEnvironment(assets, log) cli.build()
filters='uglifyjs', output='js/electris-footer.min.js') css = Bundle( 'bootstrap/css/bootstrap.min.css', 'bootstrap/css/bootstrap-responsive.min.css', 'css/template.css', 'css/app.css', 'css/sponsorship.css', filters='yui_css', output='css/electris.min.css') static.register('js_header', header_js) static.register('js_footer', footer_js) static.register('css', css) header_js.urls() footer_js.urls() css.urls() import logging from webassets.script import CommandLineEnvironment # Setup a logger log = logging.getLogger('webassets') log.addHandler(logging.StreamHandler()) log.setLevel(logging.DEBUG) cmdenv = CommandLineEnvironment(static, log) cmdenv.watch()
def watch_assets(): log = logging.getLogger('webassets') log.addHandler(logging.StreamHandler()) log.setLevel(logging.DEBUG) cmdenv = CommandLineEnvironment(assets_env, log) cmdenv.watch()
import logging from webassets import Environment from webassets import Bundle from webassets.script import CommandLineEnvironment # Bundle and minify the javascript # Since Flask isn't serving the JS this needs to be done here # before the static files are pulled down on nginx # Kind of not the way I was hoping to handle this log = logging.getLogger('webassets') log.addHandler(logging.StreamHandler()) log.setLevel(logging.DEBUG) env = Environment('mojibake/static', '/static') js = Bundle('js/jquery.min.js', 'js/jquery-ui.custom.js', 'js/skel.min.js', 'js/skel-panels.min.js', 'js/init.js', 'js/mojibake.js', filters='jsmin', output='js/packed.js') env.register('js_all', js) # From the docs # https://webassets.readthedocs.org/en/latest/script.html cmdenv = CommandLineEnvironment(env, log) cmdenv.build()
def setup(self): super(TestCLI, self).setup() self.assets_env = self.env self.cmd_env = CommandLineEnvironment(self.assets_env, logging)
def compile(): assets_cle = CommandLineEnvironment(current_app.assets, current_app.logger) assets_cle.build()