-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
60 lines (51 loc) · 1.68 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// browser-sync watched files
// automatically reloads the page when files changed
var browserSyncWatchFiles = [
'./assets/css/*.css',
'./assets/js/*.js',
'./libraries/**/*.php',
'./modules/**/*.php',
'./partials/**/*.php',
'./setup/**/*.php',
'./*.php',
];
// browser-sync options
// see: https://www.browsersync.io/docs/options/
var browserSyncOptions = {
proxy: "http://porto.local/",
host: "porto.local",
open: "external",
notify: false
};
// Defining requirements
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
/* ================= WATCHER ================== */
gulp.task('bs', function () {
browserSync.init(browserSyncWatchFiles, browserSyncOptions);
});
var sass = require('gulp-sass');
var rename = require("gulp-rename");
var sourcemaps = require('gulp-sourcemaps');
sass.compiler = require('node-sass');
gulp.task('sass', function () {
return gulp.src('./assets/css/style.scss')
.pipe(sourcemaps.init())
.pipe(sass({ outputStyle: 'compressed' }).on('error', sass.logError))
.pipe(rename('style.min.css'))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./assets/css'));
});
gulp.task('watchSass', function () {
gulp.watch('./assets/css/sass/**/*.scss', gulp.series(['sass']));
});
const webpack = require('webpack');
const gulpWebpack = require('webpack-stream');
var webpackConfig = require('./webpack.config.js')
var webpackDevConfig = { ...webpackConfig, mode: 'development', watch: true }
gulp.task('webpack', function () {
return gulp.src('./react/index.js')
.pipe(gulpWebpack(webpackDevConfig, webpack))
.pipe(gulp.dest('./assets/js/'));
});
gulp.task('default', gulp.parallel(['watchSass', 'webpack', 'bs']))