Пример #1
0
def _setup_env(debug=True, cache=True):
    """Setup the webassets environment."""
    env = Environment(INPUT_FILES, OUTPUT_FILES)
    # We use underscore's templates by default.
    env.config['JST_COMPILER'] = '_.template'
    if debug:
        env.config['CLOSURE_COMPRESSOR_OPTIMIZATION'] = 'WHITESPACE_ONLY'
        env.manifest = False
    else:
        env.config['CLOSURE_COMPRESSOR_OPTIMIZATION'] = 'ADVANCED_OPTIMIZATIONS'

    env.debug = False
    env.cache = cache

    #javascript
    _bundle_app_jsts(env, debug)
    _bundle_app_coffee(env, debug)
    _bundle_3rd_party_js(env, debug)

    #css
    _bundle_app_less(env, debug)
    _bundle_3rd_party_css(env, debug)

    #images
    _bundle_images(env)

    return env
Пример #2
0
def _setup_env(app='', debug=True, cache=True):
    """Setup the webassets environment."""
    if app:
        app_path = path.join('..', '..', app, 'static')
        env = Environment(path.join(INPUT_FILES, '..', '..', 'skel', 'assets'),
                          path.join(BASE_LOCATION, '..'))
    else:
        app_path = path.join('..', 'static')
        env = Environment(path.join(INPUT_FILES, '..', '..', 'skel', 'assets'),
                          path.join(BASE_LOCATION))

    # We use underscore's templates by default.
    env.config['JST_COMPILER'] = '_.template'
    if debug:
        env.config['CLOSURE_COMPRESSOR_OPTIMIZATION'] = 'WHITESPACE_ONLY'
        env.manifest = False
    else:
        env.config[
            'CLOSURE_COMPRESSOR_OPTIMIZATION'] = 'ADVANCED_OPTIMIZATIONS'

    env.debug = False
    env.cache = cache

    #javascript
    _bundle_skel(app_path, env, debug)

    #css
    _bundle_3rd_party_css(app_path, env, debug)

    #images
    _bundle_images(app, env, is_skel=True)

    return env
Пример #3
0
def _setup_env(debug=True, cache=True):
    """Setup the webassets environment."""
    env = Environment(INPUT_FILES, OUTPUT_FILES)
    # We use underscore's templates by default.
    env.config['JST_COMPILER'] = '_.template'
    if debug:
        env.config['CLOSURE_COMPRESSOR_OPTIMIZATION'] = 'WHITESPACE_ONLY'
        env.manifest = False
    else:
        env.config[
            'CLOSURE_COMPRESSOR_OPTIMIZATION'] = 'ADVANCED_OPTIMIZATIONS'

    env.debug = False
    env.cache = cache

    #javascript
    _bundle_app_jsts(env, debug)
    _bundle_app_coffee(env, debug)
    _bundle_3rd_party_js(env, debug)

    #css
    _bundle_app_less(env, debug)
    _bundle_3rd_party_css(env, debug)

    #images
    _bundle_images(env)

    return env
Пример #4
0
def _setup_env(app='', debug=True, cache=True):
    """Setup the webassets environment."""
    if app:
        app_path = path.join('..', '..', app, 'static')
        env = Environment(
            path.join(INPUT_FILES, '..', '..', 'skel', 'assets'),
            path.join(BASE_LOCATION, '..'))
    else:
        app_path = path.join('..', 'static')
        env = Environment(
            path.join(INPUT_FILES, '..', '..', 'skel', 'assets'),
            path.join(BASE_LOCATION))

    # We use underscore's templates by default.
    env.config['JST_COMPILER'] = '_.template'
    if debug:
        env.config['CLOSURE_COMPRESSOR_OPTIMIZATION'] = 'WHITESPACE_ONLY'
        env.manifest = False
    else:
        env.config['CLOSURE_COMPRESSOR_OPTIMIZATION'] = 'ADVANCED_OPTIMIZATIONS'

    env.debug = False
    env.cache = cache

    #javascript
    _bundle_app_coffee(app_path, env, debug)
    _bundle_3rd_party_js(app_path, env, debug)

    #css
    _bundle_3rd_party_css(app_path, env, debug)

    #images
    _bundle_images(app, env, is_skel=True)

    return env
Пример #5
0
def _set_env(debug=True, cache=False):
    env = Environment(BASE_PATH)

    if debug:
        env.manifest = False

    env.cache = cache

    return env
Пример #6
0
def includeme(config):
    """pyramid include. declare the add_thumb_view"""
    here = os.path.dirname(__file__)
    settings = config.registry.settings

    config_dir = settings.get('garasu_webassets.config', '{}/configs'.format(here))
    LOG.debug(config_dir)
    # config_dir = AssetResolver(None).resolve(config_dir).abspath()
    asset_dir = settings.get('garasu_webassets.assets', '{}/assets'.format(here))
    LOG.debug(asset_dir)
    # asset_dir = AssetResolver(None).resolve(asset_dir).abspath()

    env = Environment(directory=asset_dir, url=settings['garasu_webassets.url'])
    env.manifest = settings['garasu_webassets.manifest']
    env.debug = asbool(settings['garasu_webassets.debug'])
    env.cache = asbool(settings['garasu_webassets.cache'])
    env.auto_build = asbool(settings['garasu_webassets.auto_build'])

    def text(value):
        if type(value) is six.binary_type:
            return value.decode('utf-8')
        else:
            return value

    def yaml_stream(fname, mode):
        if path.exists(fname):
            return open(fname, mode)
        raise FileNotFoundError

    fin = fileinput.input('/'.join([config_dir, settings['garasu_webassets.bundles']]),
                          openhook=yaml_stream)
    with closing(fin):
        lines = [text(line).rstrip() for line in fin]

    stream_yaml = six.StringIO('\n'.join(lines))
    loader = YAMLLoader(stream_yaml)
    result = loader.load_bundles()
    env.register(result)

    # for item in env:
    #     LOG.debug(item.output)
    #     path_file = '/'.join([public_dir, item.output])
    #     src_file = '/'.join([asset_dir, item.output])
    #     shutil.copy(src_file, path_file)

    def _get_assets(request, *args, **kwargs):
        bundle = Bundle(*args, **kwargs)
        with bundle.bind(env):
            urls = bundle.urls()
        return urls
    config.add_request_method(_get_assets, 'web_assets')

    def _get_assets_env(request):
        return env
    config.add_request_method(_get_assets_env, 'web_env', reify=True)
Пример #7
0
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()
Пример #8
0
#!/usr/bin/env python
from os import path
from webassets import Bundle, Environment

env = Environment(path.join(path.dirname(__file__), 'static'), '/stylesheets')
# App Engine doesn't support automatic rebuilding.
env.auto_build = False
# This file needs to be shipped with your code.
env.manifest = 'file'

bundle = Bundle('in.css', filters="cssmin", output="out.css")
env.add(bundle)


if __name__== "__main__":
    # If this file is called directly, do a manual build.
    bundle.build()
import os

from werkzeug.wrappers import Request, Response
from werkzeug.wsgi import SharedDataMiddleware

from webassets import Environment, Bundle, ExternalAssets

environment = Environment('static', '/static')

environment.versions = 'hash'
manifest_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '.static-manifest'))
environment.manifest = 'file://%s' % manifest_path
environment.cache = False
environment.auto_build = True
environment.url = '//0.0.0.0:5001/static/'
#environment.debug = True

#less = Bundle('less/main.less', filters='less', output='gencss/less.css')

css = Bundle(
    Bundle('less/main.less', filters='less', output='gencss/less.css'),
    'css/main.css',
    'css/sub/sub-main.css',
    filters='cssrewrite',
    output='gencss/css-merged.%(version)s.css'
)

external_solo = ExternalAssets('map.png')

external_main = ExternalAssets(
    'css/img/*',
Пример #10
0
#!/usr/bin/env python
from os import path
from webassets import Bundle, Environment

env = Environment(path.join(path.dirname(__file__), 'static'), '/stylesheets')
# App Engine doesn't support automatic rebuilding.
env.auto_build = False
# This file needs to be shipped with your code.
env.manifest = 'file'

bundle = Bundle('in.css', filters="cssmin", output="out.css")
env.add(bundle)

if __name__ == "__main__":
    # If this file is called directly, do a manual build.
    bundle.build()