dist builder
This commit is contained in:
parent
0f6f4170db
commit
919f6a0188
@ -19,3 +19,7 @@ indent_size = 2
|
|||||||
[*.js]
|
[*.js]
|
||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.py]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
src/assets/
|
src/assets/
|
||||||
|
dist/
|
||||||
|
47
mkdist.py
Executable file
47
mkdist.py
Executable file
@ -0,0 +1,47 @@
|
|||||||
|
#!/bin/env python3
|
||||||
|
import os
|
||||||
|
import minify_html
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
HTML_SRC = ''
|
||||||
|
CSS_SRC = ''
|
||||||
|
|
||||||
|
# Preparing, check dirs
|
||||||
|
if not os.path.isdir('dist'):
|
||||||
|
os.mkdir('dist')
|
||||||
|
|
||||||
|
# Build HTML
|
||||||
|
with open('src/index.html') as file:
|
||||||
|
HTML_SRC = file.read()
|
||||||
|
|
||||||
|
minified = minify_html.minify(HTML_SRC, minify_js=True, do_not_minify_doctype=True, ensure_spec_compliant_unquoted_attribute_values=False, remove_processing_instructions=True)
|
||||||
|
|
||||||
|
# Fix minify_html bugs for W3C validator
|
||||||
|
minified = minified.replace('content=width=device-width,initial-scale=1', 'content="width=device-width, initial-scale=1"')
|
||||||
|
minified = minified.replace('icon"href', 'icon" href')
|
||||||
|
minified = minified.replace('«', '«')
|
||||||
|
minified = minified.replace('»', '»')
|
||||||
|
HTML_SRC = minified
|
||||||
|
|
||||||
|
# Save HTML
|
||||||
|
with open('dist/index.html', 'w') as file:
|
||||||
|
file.write(HTML_SRC)
|
||||||
|
|
||||||
|
# Build CSS
|
||||||
|
with open('src/styles.css') as file:
|
||||||
|
CSS_SRC = file.read()
|
||||||
|
|
||||||
|
minified = minify_html.minify(CSS_SRC, minify_css=True, remove_processing_instructions=True)
|
||||||
|
CSS_SRC = minified
|
||||||
|
|
||||||
|
# Save CSS
|
||||||
|
with open('dist/styles.css', 'w') as file:
|
||||||
|
file.write(CSS_SRC)
|
||||||
|
|
||||||
|
# Copy other files
|
||||||
|
os.popen('cp src/favicon.ico src/humans.txt dist/' )
|
||||||
|
|
||||||
|
# Make archive
|
||||||
|
os.popen('cd ./dist/; tar -czf ../dist.tar.gz *')
|
||||||
|
# os.popen('rm -rf ./dist/')
|
@ -1 +1,2 @@
|
|||||||
editorconfig-checker==2.4.0
|
editorconfig-checker==2.4.0
|
||||||
|
minify_html==0.8.0
|
||||||
|
Loading…
Reference in New Issue
Block a user