2017-01-10 09:09:30 +00:00
|
|
|
from pelican import signals
|
2017-01-13 19:38:29 +00:00
|
|
|
from plugins.utils import node_bin, run_command, NODE_PRODUCTION
|
2017-01-10 22:14:11 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
logger = logging.getLogger(__file__)
|
2017-01-10 09:09:30 +00:00
|
|
|
|
2017-01-10 22:14:11 +00:00
|
|
|
|
2017-01-10 09:09:30 +00:00
|
|
|
def static_build(*args, **kwargs):
|
2017-01-13 21:41:40 +00:00
|
|
|
return
|
2017-01-10 17:52:42 +00:00
|
|
|
if NODE_PRODUCTION:
|
2017-01-10 22:14:11 +00:00
|
|
|
logger.info('Building Production...')
|
|
|
|
UGLIFY_ARGS = ['--compress', '--screw-ie8', '--define', '--stats', '--keep-fnames']
|
|
|
|
else:
|
|
|
|
UGLIFY_ARGS = []
|
2017-01-13 19:38:29 +00:00
|
|
|
run_command('Copying Fonts', ['cp', '-r', 'node_modules/font-awesome/fonts', 'theme/static/build/'])
|
2017-01-11 09:03:49 +00:00
|
|
|
run_command('Building Bootstrap', [node_bin('uglifyjs'), 'node_modules/bootstrap-sass/assets/javascripts/bootstrap.js', UGLIFY_ARGS, '-o', 'theme/static/build/js/bootstrap.js'])
|
2017-01-10 22:14:11 +00:00
|
|
|
run_command('Building jQuery', [node_bin('uglifyjs'), 'node_modules/jquery/dist/jquery.js', UGLIFY_ARGS, '-o', 'theme/static/build/js/jquery.js'])
|
|
|
|
run_command('Building Application', [
|
|
|
|
node_bin('browserify'),
|
|
|
|
'theme/static/src/js/app.js',
|
|
|
|
'-o', 'theme/static/build/js/app.js'
|
|
|
|
])
|
|
|
|
|
|
|
|
logger.info('JS built!')
|
|
|
|
|
|
|
|
run_command('Building Pygments Style', ['pygmentize', '-S', 'github', '-f', 'html', '-a', '.highlight', '>', 'theme/static/src/scss/pygment.css'], True)
|
|
|
|
run_command('Building Styles', [node_bin('node-sass'), 'theme/static/src/scss/index.scss', 'theme/static/build/css/index.css', '--source-map-embed'])
|
|
|
|
|
|
|
|
logger.info('SCSS Built!')
|
|
|
|
|
2017-01-11 08:37:45 +00:00
|
|
|
if NODE_PRODUCTION:
|
|
|
|
run_command('Compressing Application', [node_bin('uglifyjs'), 'theme/static/build/js/app.js', UGLIFY_ARGS, '-o', 'theme/static/build/js/app.js'])
|
|
|
|
run_command('Prefixing Styles', [node_bin('postcss'), '-u', 'autoprefixer', '-o', 'theme/static/build/css/index.css', 'theme/static/build/css/index.css'])
|
|
|
|
run_command('Compressing Styles', [node_bin('cleancss'), '-d', '--s0', '-o', 'theme/static/build/css/index.css', 'theme/static/build/css/index.css'])
|
|
|
|
|
2017-01-10 09:09:30 +00:00
|
|
|
|
|
|
|
def register():
|
|
|
|
signals.static_generator_init.connect(static_build)
|