canape/gulpfile.babel.js

66 lines
1.5 KiB
JavaScript

import gulp from 'gulp';
import babel from 'gulp-babel';
import less from 'gulp-less';
import del from 'del';
import webpack from 'webpack-stream';
import webpackConfig from './webpack.config.babel';
const paths = {
allSrcJs: 'src/**/*.js?(x)',
jsSrc: 'src/public/js/app.js',
jsDistDir: 'build/public/js',
lessSrc: 'src/public/less/app.less',
lessDest: 'build/public/css',
fontSrc: [
'./node_modules/font-awesome/fonts/*',
'./node_modules/bootstrap/fonts/*',
],
fontDest: 'build/public/fonts',
imgSrc: 'src/public/img/*',
imgDest: 'build/public/img/',
htmlSrc: 'src/public/index.html',
htmlDest: 'build/public/',
gulpFile: 'gulpfile.babel.js',
webpackFile: 'webpack.config.babel.js',
};
gulp.task('less', () =>
gulp.src(paths.lessSrc)
.pipe(less({
paths: [ './node_modules' ]
}))
.pipe(gulp.dest(paths.lessDest))
);
gulp.task('fonts', () =>
gulp.src(paths.fontSrc)
.pipe(gulp.dest(paths.fontDest))
);
gulp.task('images', () =>
gulp.src(paths.imgSrc)
.pipe(gulp.dest(paths.imgDest))
);
gulp.task('html', () =>
gulp.src(paths.htmlSrc)
.pipe(gulp.dest(paths.htmlDest))
);
gulp.task('js', () =>
gulp.src(paths.jsSrc)
.pipe(webpack(webpackConfig))
.pipe(gulp.dest(paths.jsDistDir))
);
gulp.task('main', ['less', 'fonts', 'images', 'html', 'js'])
gulp.task('watch', () => {
gulp.watch(paths.allSrcJs, ['js']);
gulp.watch(paths.lessSrc, ['less']);
gulp.watch(paths.imgSrc, ['images']);
gulp.watch(paths.htmlSrc, ['html']);
});
gulp.task('default', ['watch', 'main']);