add option to copy files while asset building
This commit is contained in:
parent
c6a5624b5b
commit
d950904eac
2 changed files with 11 additions and 6 deletions
|
|
@ -11,10 +11,10 @@ Build the `public` folders and setup languages
|
|||
import os, sys, frappe, json, shutil
|
||||
from cssmin import cssmin
|
||||
|
||||
def bundle(no_compress):
|
||||
def bundle(no_compress, make_copy=False):
|
||||
"""concat / minify js files"""
|
||||
# build js files
|
||||
make_asset_dirs()
|
||||
make_asset_dirs(make_copy=make_copy)
|
||||
build(no_compress)
|
||||
|
||||
def watch(no_compress):
|
||||
|
|
@ -28,7 +28,7 @@ def watch(no_compress):
|
|||
|
||||
time.sleep(3)
|
||||
|
||||
def make_asset_dirs():
|
||||
def make_asset_dirs(make_copy=False):
|
||||
assets_path = os.path.join(frappe.local.sites_path, "assets")
|
||||
for dir_path in [
|
||||
os.path.join(assets_path, 'js'),
|
||||
|
|
@ -44,7 +44,10 @@ def make_asset_dirs():
|
|||
target = os.path.join(assets_path, app_name)
|
||||
|
||||
if not os.path.exists(target) and os.path.exists(source):
|
||||
os.symlink(os.path.abspath(source), target)
|
||||
if make_copy:
|
||||
shutil.copytree(os.path.abspath(source), target)
|
||||
else:
|
||||
os.symlink(os.path.abspath(source), target)
|
||||
|
||||
def build(no_compress=False):
|
||||
assets_path = os.path.join(frappe.local.sites_path, "assets")
|
||||
|
|
|
|||
|
|
@ -156,6 +156,8 @@ def setup_utilities(parser):
|
|||
# build
|
||||
parser.add_argument("-b", "--build", default=False, action="store_true",
|
||||
help="Minify + concatenate JS and CSS files, build translations")
|
||||
parser.add_argument("--make_copy", default=False, action="store_true",
|
||||
help="Make copy of assets instead of symlinks")
|
||||
parser.add_argument("-w", "--watch", default=False, action="store_true",
|
||||
help="Watch and concatenate JS and CSS files as and when they change")
|
||||
|
||||
|
|
@ -379,10 +381,10 @@ def reload_doc(module, doctype, docname, force=False):
|
|||
frappe.destroy()
|
||||
|
||||
@cmd
|
||||
def build():
|
||||
def build(make_copy=False):
|
||||
import frappe.build
|
||||
import frappe
|
||||
frappe.build.bundle(False)
|
||||
frappe.build.bundle(False, make_copy=make_copy)
|
||||
|
||||
@cmd
|
||||
def watch():
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue