本文整理汇总了Python中flask_assets.Bundle方法的典型用法代码示例。如果您正苦于以下问题:Python flask_assets.Bundle方法的具体用法?Python flask_assets.Bundle怎么用?Python flask_assets.Bundle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flask_assets
的用法示例。
在下文中一共展示了flask_assets.Bundle方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compile_auth_assets
# 需要导入模块: import flask_assets [as 别名]
# 或者: from flask_assets import Bundle [as 别名]
def compile_auth_assets(app):
"""Configure authorization asset bundles."""
assets = Environment(app)
Environment.auto_build = True
Environment.debug = False
# Stylesheets Bundle
less_bundle = Bundle(
'src/less/account.less',
filters='less,cssmin',
output='dist/css/account.css',
extra={'rel': 'stylesheet/less'}
)
# JavaScript Bundle
js_bundle = Bundle(
'src/js/main.js',
filters='jsmin',
output='dist/js/main.min.js'
)
# Register assets
assets.register('less_all', less_bundle)
assets.register('js_all', js_bundle)
# Build assets in development mode
if app.config['FLASK_ENV'] == 'development':
less_bundle.build(force=True)
js_bundle.build()
示例2: compile_main_assets
# 需要导入模块: import flask_assets [as 别名]
# 或者: from flask_assets import Bundle [as 别名]
def compile_main_assets(app):
"""Configure logged-in asset bundles."""
assets = Environment(app)
Environment.auto_build = True
Environment.debug = False
# Stylesheets Bundle
less_bundle = Bundle(
'src/less/dashboard.less',
filters='less,cssmin',
output='dist/css/dashboard.css',
extra={'rel': 'stylesheet/less'}
)
# Register assets
assets.register('less_all', less_bundle)
# Build assets in development mode
if app.config['FLASK_ENV'] == 'development':
less_bundle.build(force=True)
示例3: compile_assets
# 需要导入模块: import flask_assets [as 别名]
# 或者: from flask_assets import Bundle [as 别名]
def compile_assets(app_assets):
"""Configure and build asset bundles."""
js_assets = ("create",
"created",
"read",
"utils/errorParser",
"utils/fetchRetry")
css_assets = ("styles", )
for code in js_assets:
bundle = Bundle(f"src/js/{code}.js",
filters="jsmin",
output=f"dist/js/{code}.min.js")
app_assets.register(code, bundle)
bundle.build()
for style in css_assets:
bundle = Bundle(f"src/css/{style}.css",
filters="cssmin",
output=f"dist/css/{style}.min.css")
app_assets.register(style, bundle)
bundle.build()
示例4: js_files
# 需要导入模块: import flask_assets [as 别名]
# 或者: from flask_assets import Bundle [as 别名]
def js_files():
js = Bundle('js/jquery.cookie.js',
'js/jquery.SuperSlide.js',
'js/autocomplete.js',
'js/spop.js',
'js/function.js',
'js/fishBone.js',
'js/dropdown.js',
'js/tooltip.min.js',
'js/clipboard.min.js',
'js/Modal.js',
'js/minigrid.js',
'js/dynamics.js',
'js/zh.js',
'js/jquery.step.min.js',
'js/jquery-rvnm.js',
'js/botui.min.js',
filters='jsmin',
output='js/js_packed.js'
)
return js
示例5: css_files
# 需要导入模块: import flask_assets [as 别名]
# 或者: from flask_assets import Bundle [as 别名]
def css_files():
css = Bundle('css/material_blue.css',
'css/mstyle.css',
'css/style.css',
'css/spop.css',
'css/fishBone.css',
'css/buttons.css',
'css/radar.css',
'css/font-awesome.min.css',
'css/jquery-rvnm.css',
'css/jquery.step.css',
'css/botui.min.css',
'css/botui-theme-default.css',
'css/mimic.css',
filters='cssmin',
output='css/css_packed.css'
)
return css
示例6: register
# 需要导入模块: import flask_assets [as 别名]
# 或者: from flask_assets import Bundle [as 别名]
def register(self, name, *args, **kwargs):
ext = args[0].split('.')[-1]
filters = kwargs.get('filters', self.default_filters[ext])
output = kwargs.get('output', self.default_output[ext])
return super(Assets, self).register(name, Bundle(*args, filters=filters, output=output))
示例7: init
# 需要导入模块: import flask_assets [as 别名]
# 或者: from flask_assets import Bundle [as 别名]
def init(app) -> None:
"""
Bundle projects assets.
:param app: Main application instance
:type app: flask.Flask
"""
assets = Environment(app)
assets.auto_build = app.config.get('ASSETS_AUTO_BUILD', True)
files_to_watch = []
if 'COLLECT_STATIC_ROOT' in app.config:
assets.cache = app.config['COLLECT_STATIC_ROOT']
collect = Collect()
collect.init_app(app)
collect.collect()
app.static_folder = app.config['COLLECT_STATIC_ROOT']
for key in ['js', 'css']:
assets_key = '%s_ASSETS' % key.upper()
build_files = app.config[assets_key]
files_to_watch.extend(_get_files_for_settings(app, assets_key))
bundle = Bundle(*build_files,
output=app.config['%s_OUTPUT' % assets_key],
filters=app.config['%s_FILTERS' % assets_key]
)
assets.register('%s_all' % key, bundle)
app.logger.debug('Bundling files: %s%s',
os.linesep,
os.linesep.join(build_files))
app.assets = assets
app._base_files_to_watch = files_to_watch
app.logger.info('Base assets are collected successfully.')
示例8: init
# 需要导入模块: import flask_assets [as 别名]
# 或者: from flask_assets import Bundle [as 别名]
def init(app):
assets = Environment(app)
js = Bundle(*app.config['JS_ASSETS'],
output=app.config['JS_ASSETS_OUTPUT'],
filters=app.config['JS_ASSETS_FILTERS'])
css = Bundle(*app.config['CSS_ASSETS'],
output=app.config['CSS_ASSETS_OUTPUT'],
filters=app.config['CSS_ASSETS_FILTERS'])
assets.register('js_all', js)
assets.register('css_all', css)
示例9: _init_plugin_assets
# 需要导入模块: import flask_assets [as 别名]
# 或者: from flask_assets import Bundle [as 别名]
def _init_plugin_assets(app, task_type, static_path) -> List[str]:
"""
Bundle plugin static files.
:param app: Main application instance.
:type app: flask.Flask
:param task_type: Plugin root instance.
:type task_type: vulyk.models.task_types.AbstractTaskType
:param static_path: Path to plugin's static folder.
:type static_path: str
:return: List of paths to plugin's asset files.
:rtype: List[str]
"""
app.logger.debug('Collecting <%s> assets.', task_type.type_name)
files_to_watch = []
assets_location_map = {
'js': task_type.JS_ASSETS,
'css': task_type.CSS_ASSETS
}
for key in assets_location_map.keys():
name = 'plugin_{key}_{task}'.format(key=key, task=task_type.type_name)
assets = assets_location_map[key]
if len(assets) > 0:
files = [os.path.join(static_path, x) for x in assets]
files_to_watch += files
folder = ['scripts', 'styles'][key == 'css']
filters_name = '{key}_ASSETS_FILTERS'.format(key=key.upper())
output_path = '{folder}/{name}.{key}'.format(folder=folder,
name=name,
key=key)
bundle = Bundle(*files,
output=output_path,
filters=app.config.get(filters_name, ''))
app.assets.register(name, bundle)
app.logger.debug('Bundling files: %s%s',
os.linesep,
os.linesep.join(files))
app.logger.debug('Finished collecting <%s> assets.', task_type.type_name)
return files_to_watch