-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove non-minified js and css files (#28)
* Update dev group name * Add command to remove non-minified files * Remove non-minified css and js files * Update version number
- Loading branch information
Showing
680 changed files
with
57 additions
and
284,513 deletions.
There are no files selected for viewing
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import os | ||
from glob import glob | ||
|
||
from django.core.management.base import BaseCommand | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Removes extra files from the dsfr/dist folder in order to save space." | ||
|
||
BASE_PATH = "dsfr/static/dsfr/dist" | ||
|
||
def handle(self, *args, **options): | ||
print("Delete CSS map files and non-minified CSS files") | ||
count = 0 | ||
all_css_map_files = self.get_files_by_ext("*.css.map") | ||
for file in all_css_map_files: | ||
os.remove(file) | ||
count += 1 | ||
|
||
all_full_css_files = self.get_non_minified_files_by_ext("*.css", ".min.css") | ||
for file in all_full_css_files: | ||
os.remove(file) | ||
count += 1 | ||
|
||
print(f"{count} files deleted.") | ||
|
||
print("Delete JS map files and non-minified files") | ||
count = 0 | ||
all_css_map_files = self.get_files_by_ext("*.js.map") | ||
for file in all_css_map_files: | ||
os.remove(file) | ||
count += 1 | ||
|
||
all_full_css_files = self.get_non_minified_files_by_ext("*.js", ".min.js") | ||
for file in all_full_css_files: | ||
os.remove(file) | ||
count += 1 | ||
|
||
print(f"{count} files deleted.") | ||
|
||
def get_files_by_ext(self, extension) -> list: | ||
return [ | ||
filename | ||
for path, directories, filenames in os.walk(self.BASE_PATH) | ||
for filename in glob(os.path.join(path, extension)) | ||
] | ||
|
||
def get_non_minified_files_by_ext(self, extension, minified_extension) -> list: | ||
return [ | ||
filename | ||
for path, directories, filenames in os.walk(self.BASE_PATH) | ||
for filename in glob(os.path.join(path, extension)) | ||
if not filename.endswith(minified_extension) | ||
] |
206 changes: 0 additions & 206 deletions
206
dsfr/static/dsfr/dist/component/accordion/accordion.css
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
73 changes: 0 additions & 73 deletions
73
dsfr/static/dsfr/dist/component/accordion/accordion.legacy.css
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
dsfr/static/dsfr/dist/component/accordion/accordion.legacy.css.map
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
dsfr/static/dsfr/dist/component/accordion/accordion.legacy.min.css.map
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.