Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cli_commands/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ module.exports = {
command: ['render', 'r'],
desc: 'renders all static files',
builder: {
'nominify': {
alias: 'm',
describe: 'Turns off file minification'
},
'nojuice': {
alias: 'j',
describe: 'no-juice',
Expand Down
4 changes: 4 additions & 0 deletions cli_commands/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ module.exports = {
command: 'start',
desc: 'starts production server',
builder: {
'nominify': {
alias: 'm',
describe: 'Turns off file minification'
},
'nojuice': {
alias: 'j',
describe: 'no-juice',
Expand Down
15 changes: 9 additions & 6 deletions libs/build_tools/js_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const gulpif = require('gulp-if')
const sourcemaps = require('gulp-sourcemaps')
const Promise = require('bluebird')
const fs = Promise.promisifyAll(require('fs-extra'))
const isProduction = () => {
return Object.keys(enduro.flags).length ? (enduro.flags._[0] === 'start' || enduro.flags._[0] === 'render') && !enduro.flags.nominify : false
}

// * enduro dependencies
const flat_helpers = require(enduro.enduro_path + '/libs/flat_db/flat_helpers')
Expand All @@ -20,16 +23,16 @@ const logger = require(enduro.enduro_path + '/libs/logger')
js_handler.prototype.init = function (gulp, browser_sync) {

// stores task name
const js_handler_task_name = 'js';
gulp.task(js_handler_task_name, function() {
const js_handler_task_name = 'js'
gulp.task(js_handler_task_name, function () {
if (enduro.config.babel || enduro.config.uglify) {
logger.timestamp('JS compiling started', 'enduro_events')
const babelConfig = enduro.config.babel || {
presets: ['es2015']
}
return gulp.src([enduro.project_path + '/assets/js/*.js',
'!' + enduro.project_path + '/assets/js/*.min.js',
'!' + enduro.project_path + '/assets/js/handlebars.js'])
'!' + enduro.project_path + '/assets/js/*.min.js',
'!' + enduro.project_path + '/assets/js/handlebars.js'])
.pipe(sourcemaps.init())
.pipe(gulpif(enduro.config.babel, babel(babelConfig)))
.on('error', function (err) {
Expand All @@ -45,7 +48,7 @@ js_handler.prototype.init = function (gulp, browser_sync) {
logger.timestamp('JS compiling finished', 'enduro_events')
})
.pipe(gulpif(enduro.config.uglify, rename({ suffix: '.min' })))
.pipe(gulpif(enduro.config.uglify, uglify()))
.pipe(gulpif(isProduction(), uglify()))
.pipe(gulp.dest(enduro.project_path + '/' + enduro.config.build_folder + '/assets/js'))
} else {
logger.timestamp('js compiling not enabled, add babel options to enduro.json to enable')
Expand All @@ -58,7 +61,7 @@ js_handler.prototype.init = function (gulp, browser_sync) {
}
})

return js_handler_task_name;
return js_handler_task_name
}

module.exports = new js_handler()
12 changes: 9 additions & 3 deletions libs/build_tools/less_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ const less = require('gulp-less')
const sourcemaps = require('gulp-sourcemaps')
const LessAutoPrefix = require('less-plugin-autoprefix')
const autoprefixer = new LessAutoPrefix({ browsers: [ 'last 5 versions' ] })
const LessCleanCSS = require('less-plugin-clean-css')
const cleanCSS = new LessCleanCSS({ advanced: true })
const gulpif = require('gulp-if')
const isProduction = () => {
return Object.keys(enduro.flags).length ? (enduro.flags._[0] === 'start' || enduro.flags._[0] === 'render') && !enduro.flags.nominify : false
}

// * enduro dependencies
const logger = require(enduro.enduro_path + '/libs/logger')
Expand All @@ -27,18 +33,18 @@ less_handler.prototype.init = function (gulp, browser_sync) {
logger.timestamp('Less compiling started', 'enduro_events')

return gulp.src(enduro.project_path + '/assets/css/*.less')
.pipe(sourcemaps.init())
.pipe(gulpif(isProduction(), sourcemaps.init()))
.pipe(less({
paths: enduro.config.less && enduro.config.less.paths || [],
plugins: [ autoprefixer ]
plugins: [ autoprefixer, (isProduction() ? cleanCSS : null) ]
}))
.on('error', function (err) {
logger.err_blockStart('Less error')
logger.err(err.message)
logger.err_blockEnd()
this.emit('end')
})
.pipe(sourcemaps.write())
.pipe(gulpif(isProduction(), sourcemaps.write()))
.pipe(gulp.dest(enduro.project_path + '/' + enduro.config.build_folder + '/assets/css'))
.pipe(browser_sync.stream())
.on('end', () => {
Expand Down
14 changes: 11 additions & 3 deletions libs/build_tools/sass_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ const sass_handler = function () {}
// * vendor dependencies
const bulkSass = require('gulp-sass-bulk-import')
const sass = require('gulp-sass')
const gulpif = require('gulp-if')
const sourcemaps = require('gulp-sourcemaps')
const autoprefixer = require('gulp-autoprefixer')
const wait = require('gulp-wait')
const isProduction = () => {
return Object.keys(enduro.flags).length ? (enduro.flags._[0] === 'start' || enduro.flags._[0] === 'render') && !enduro.flags.nominify : false
}

// * enduro dependencies
const logger = require(enduro.enduro_path + '/libs/logger')
Expand All @@ -27,8 +32,11 @@ sass_handler.prototype.init = function (gulp, browser_sync) {

return gulp.src(enduro.project_path + '/assets/css/*.scss')
.pipe(bulkSass())
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(gulpif(!isProduction(), sourcemaps.init()))
.pipe(wait(500))
.pipe(sass({
outputStyle: isProduction() ? 'compressed' : 'nested'
}))
.on('error', function (err) {
logger.err_blockStart('Sass error')
logger.err(err.message)
Expand All @@ -39,7 +47,7 @@ sass_handler.prototype.init = function (gulp, browser_sync) {
browsers: ['last 2 versions'],
cascade: false,
}))
.pipe(sourcemaps.write())
.pipe(gulpif(!isProduction(), sourcemaps.write()))
.pipe(gulp.dest(enduro.project_path + '/' + enduro.config.build_folder + '/assets/css'))
.pipe(browser_sync.stream())
.on('end', () => {
Expand Down
11 changes: 8 additions & 3 deletions libs/build_tools/stylus_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ const stylus_handler = function () {}
const stylus = require('gulp-stylus')
const sourcemaps = require('gulp-sourcemaps')
const autoprefixer = require('autoprefixer-stylus')
const gulpif = require('gulp-if')
const isProduction = () => {
return Object.keys(enduro.flags).length ? (enduro.flags._[0] === 'start' || enduro.flags._[0] === 'render') && !enduro.flags.nominify : false
}

// * enduro dependencies
const logger = require(enduro.enduro_path + '/libs/logger')
Expand All @@ -25,17 +29,18 @@ stylus_handler.prototype.init = function (gulp, browser_sync) {
logger.timestamp('Stylus compiling started', 'enduro_events')

return gulp.src(enduro.project_path + '/assets/css/*.styl')
.pipe(sourcemaps.init())
.pipe(gulpif(!isProduction(), sourcemaps.init()))
.pipe(stylus({
use: [ autoprefixer('last 5 versions') ]
use: [ autoprefixer('last 5 versions') ],
compress: isProduction()
}))
.on('error', function (err) {
logger.err_blockStart('Stylus error')
logger.err(err.message)
logger.err_blockEnd()
this.emit('end')
})
.pipe(sourcemaps.write())
.pipe(gulpif(!isProduction(), sourcemaps.write()))
.pipe(gulp.dest(enduro.project_path + '/' + enduro.config.build_folder + '/assets/css'))
.pipe(browser_sync.stream())
.on('end', () => {
Expand Down
4 changes: 4 additions & 0 deletions libs/cli_tools/flag_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ const FLAG_MAP = {
nojuice: {
label: 'nojuice',
message: 'will turn off juicebox'
},
nominify: {
label: 'nominify',
message: 'will not minify css and js files'
}
}

Expand Down
2 changes: 1 addition & 1 deletion libs/enduro_server/enduro_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ enduro_server.prototype.run = function (server_setup) {
.then(() => {

let requested_url = req.url

requested_url = requested_url.split('?')[0]
let a = requested_url.split('/').filter(x => x.length)
// serves index.html when empty or culture-only url is provided
if (requested_url.length <= 1 ||
Expand Down
Loading