Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
hshassets
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
django
hshassets
Commits
c02b72d9
Commit
c02b72d9
authored
7 years ago
by
Dennis Ahrens
Browse files
Options
Downloads
Patches
Plain Diff
This should also work for watchassets, of course...
parent
2e8d5a60
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!1
Support multiple scss include paths
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
hshassets/management/commands/watchassets.py
+10
-4
10 additions, 4 deletions
hshassets/management/commands/watchassets.py
hshassets/utils.py
+2
-2
2 additions, 2 deletions
hshassets/utils.py
with
12 additions
and
6 deletions
hshassets/management/commands/watchassets.py
+
10
−
4
View file @
c02b72d9
...
@@ -10,12 +10,16 @@ from watchdog.observers import Observer
...
@@ -10,12 +10,16 @@ from watchdog.observers import Observer
class
AssetBuildHandler
(
events
.
PatternMatchingEventHandler
):
class
AssetBuildHandler
(
events
.
PatternMatchingEventHandler
):
def
__init__
(
self
,
scss_include_paths
,
*
args
,
**
kwargs
):
super
().
__init__
(
*
args
,
**
kwargs
)
self
.
scss_include_paths
=
scss_include_paths
def
on_modified
(
self
,
event
):
def
on_modified
(
self
,
event
):
if
isinstance
(
event
,
events
.
FileModifiedEvent
):
if
isinstance
(
event
,
events
.
FileModifiedEvent
):
print
(
'
File modified:
\033
[35m{}
\033
[0m
'
.
format
(
event
.
src_path
))
print
(
'
File modified:
\033
[35m{}
\033
[0m
'
.
format
(
event
.
src_path
))
try
:
try
:
app_name
,
app_directories
=
utils
.
discover_app
(
event
.
src_path
)
app_name
,
app_directories
=
utils
.
discover_app
(
event
.
src_path
)
utils
.
build_specific
(
app_name
,
app_directories
,
event
.
src_path
)
utils
.
build_specific
(
app_name
,
app_directories
,
event
.
src_path
,
self
.
scss_include_paths
)
except
Exception
as
e
:
except
Exception
as
e
:
print
(
'
Failed!
\033
[31m(✖_✖)
\033
[0m
\n
'
)
print
(
'
Failed!
\033
[31m(✖_✖)
\033
[0m
\n
'
)
traceback
.
print_exc
()
traceback
.
print_exc
()
...
@@ -47,10 +51,12 @@ class Command(BaseCommand):
...
@@ -47,10 +51,12 @@ class Command(BaseCommand):
observer
=
Observer
()
observer
=
Observer
()
build_handler
=
AssetBuildHandler
(
patterns
=
[
'
*.js
'
,
'
*.sass
'
,
'
*.scss
'
,
'
*.css
'
]
)
asset_directories
=
utils
.
get_asset_directories
(
)
image_handler
=
ImageHandler
(
patterns
=
[
'
*
'
]
)
scss_include_paths
=
utils
.
get_scss_include_paths
(
asset_directories
)
for
app_name
,
app_directories
in
utils
.
get_asset_directories
().
items
():
build_handler
=
AssetBuildHandler
(
scss_include_paths
,
patterns
=
[
'
*.js
'
,
'
*.sass
'
,
'
*.scss
'
,
'
*.css
'
])
image_handler
=
ImageHandler
(
patterns
=
[
'
*
'
])
for
app_name
,
app_directories
in
asset_directories
.
items
():
if
not
os
.
path
.
isdir
(
app_directories
[
'
static_path
'
]):
if
not
os
.
path
.
isdir
(
app_directories
[
'
static_path
'
]):
os
.
makedirs
(
app_directories
[
'
static_path
'
])
os
.
makedirs
(
app_directories
[
'
static_path
'
])
...
...
This diff is collapsed.
Click to expand it.
hshassets/utils.py
+
2
−
2
View file @
c02b72d9
...
@@ -217,8 +217,8 @@ def do_everything(verbose=False):
...
@@ -217,8 +217,8 @@ def do_everything(verbose=False):
copy_fonts
(
app_name
,
app_directories
,
verbose
=
verbose
)
copy_fonts
(
app_name
,
app_directories
,
verbose
=
verbose
)
def
build_specific
(
app_name
,
app_directories
,
file_path
):
def
build_specific
(
app_name
,
app_directories
,
file_path
,
scss_include_paths
):
if
file_path
.
endswith
((
'
.sass
'
,
'
.scss
'
,
'
.css
'
)):
if
file_path
.
endswith
((
'
.sass
'
,
'
.scss
'
,
'
.css
'
)):
build_scss
(
app_name
,
app_directories
)
build_scss
(
app_name
,
app_directories
,
scss_include_paths
)
elif
file_path
.
endswith
((
'
.js
'
)):
elif
file_path
.
endswith
((
'
.js
'
)):
build_javascript
(
app_name
,
app_directories
)
build_javascript
(
app_name
,
app_directories
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment