-
- PyPI:https://www.ctyun.cn/portal/link.html?target=https%3A%2F%2Fpypi.org%2Fproject%2Fwebassets%2F
- Github: https://www.ctyun.cn/portal/link.html?target=https%3A%2F%2Fgithub.com%2Fmiracle2k%2Fwebassets
- Doc: https://www.ctyun.cn/portal/link.html?target=https%3A%2F%2Fwebassets.readthedocs.io%2F
*
个人感觉是Python版的webpack
安装
pip install webassets
使用示例
from webassets import Environment, Bundle
assets_env = Environment(
directory='./static',
url='/static')
common_js = Bundle(
'js/common-1.js',
'js/common-2.js',
filters='jsmin',
output='js/common.js')
assets_env.register('common_js', common_js)
print(assets_env['common_js'].urls())
# ['/static/js/common.js?207d589d']
assets_env.debug = True
print(assets_env['common_js'].urls())
# ['/static/js/common-1.js', '/static/js/common-2.js']
输入文件
static/js/common-1.js
function foo1() {
}
static/js/common-2.js
function foo2() {
}
输出文件
static/js/common.js
function foo1(){}
function foo2(){}