geolets/gulp/config.js
2016-07-14 17:15:55 +02:00

157 lines
4.0 KiB
JavaScript

'use strict';
const p = require('path');
const fs = require('fs');
const port = fs.existsSync(p.join(PWD, 'server/config/port.js')) ?
require(p.join(PWD, 'server/config/port')) : null;
module.exports = {
browserSync: {
browser: null,
ghostMode: false,
proxy: 'localhost:' + (port || 10000),
port: 1337,
ui: {
port: 1338
},
files: [
p.join(PWD, 'public/css/**/*.css'),
p.join(PWD, 'public/js/**/*.js'),
]
},
browserify: {
suffix: true,
debug: true,
dest: p.join(PWD, 'public/js'),
extensions: [ '.js', '.jsx', '.json' ],
// PWD/node_modules is added so symlinked ridge does not break. used to
// work without this in browserify 9
paths: [ p.join(PWD, 'node_modules'), p.join(PWD, 'modules') ],
// outputs only need to be used if output names are different from entries.
// Otherwise the entries array is copied into the outputs array.
entries: [
'app.js'
],
src: p.join(PWD, 'src')
},
less: {
suffix: true,
src: [
p.join(PWD, 'less/**/main.less')
],
dest: p.join(PWD, 'public/css'),
autoprefixer: {
browsers: [
'safari >= 5',
'ie >= 8',
'ios >= 6',
'opera >= 12.1',
'firefox >= 17',
'chrome >= 30',
'android >= 4'
],
cascade: true
},
functions: {
'img-url': function (value) {
const tree = this.context.pluginManager.less.tree;
return new tree.URL(new tree.Quoted('"', p.join('/img', value.value)), this.index, this.currentFileInfo);
},
rem: function (value, context) {
const tree = this.context.pluginManager.less.tree;
if (value.type === 'Expression')
return new tree.Expression(value.value.map((value) => {
if (value.unit.backupUnit === 'px')
return new tree.Dimension(value.value / 14, 'rem');
return new tree.Dimension(value.value, 'rem');
}));
return new tree.Dimension(value.value / 14, 'rem');
},
px: function (value) {
const tree = this.context.pluginManager.less.tree;
if (value.type === 'Expression')
return new tree.Expression(value.value.map((value) => {
if (value.unit.backupUnit === 'px')
return value;
return new tree.Dimension(value.value * 14, 'px');
}));
if (value.unit.backupUnit === 'px')
return value;
return new tree.Dimension(value.value * 14, 'px');
}
},
options: {
paths: [
p.join(PWD, 'node_modules/spineless/less')
],
}
},
nodemon: {
ext: 'js,marko',
ignore: ['*.marko.js', 'src/**/*.js' ],
watch: [
'src',
'modules',
'server'
],
script: fs.existsSync(p.join(PWD, 'package.json')) ? require(p.join(PWD, 'package.json')).main.replace(/^\./, PWD) : 'server/server.js',
env: {
BABEL_ENV: 'server',
// what port you actually put into the browser... when using browser-sync
// this will differ from the internal port used by express
EXTERNAL_PORT: 1337,
// needed to force debug to use colors despite tty.istty(0) being false,
// which it is in a child process
DEBUG_COLORS: true,
// needed to force chalk to use when running gulp nodemon tasks.
FORCE_COLOR: true,
PWD,
NODE_ENV: ENV,
DEBUG: 'hats:contact'
}
},
raster: {
src: p.join(PWD, 'img/raster/**/*.{png,gif,jpg}'),
dest: p.join(PWD, 'public/img')
},
static: {
src: p.join(PWD, 'static/**/*'),
dest: p.join(PWD, 'public')
},
svg: {
src: p.join(PWD, 'img/svg/**/*.svg'),
dest: p.join(PWD, 'public/img')
},
tasks: {
development: [ 'wipe', [ 'browserify', 'raster', 'less', 'static', 'svg' ], [ 'nodemon' ], [ 'watch', 'browser-sync' ] ],
production: [ 'wipe', [ 'browserify', 'raster', 'less', 'static', 'svg' ]]
}[ENV],
watch: {
//sass: p.join(PWD, 'sass/**/*.{sass,scss}')
less: p.join(PWD, 'less/**/*.less')
},
wipe: {
src: [ p.join(PWD, 'public') ]
},
};