-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
64 lines (56 loc) · 1.74 KB
/
gulpfile.js
File metadata and controls
64 lines (56 loc) · 1.74 KB
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
61
62
63
64
var webpackDevMiddleware = require('webpack-dev-middleware');
var webpackHotMiddleware = require('webpack-hot-middleware');
var webpackConfig = require('./webpack.config');
var autoprefixer = require('gulp-autoprefixer');
var browserSync = require('browser-sync');
var stylus = require('gulp-stylus');
var webpack = require('webpack');
var gulp = require('gulp');
var compiler = webpack(webpackConfig);
gulp.task('stylus', function () {
return gulp.src(['src/css/app.styl'])
.pipe(stylus({ linenos: true }))
.pipe(autoprefixer())
.pipe(gulp.dest('public/css'));
});
gulp.task('stylus-production', function () {
return gulp.src(['src/css/app.styl'])
.pipe(stylus({ compress: true }))
.pipe(autoprefixer())
.pipe(gulp.dest('dist/css'));
});
gulp.task('copy-html', function () {
return gulp.src(['src/**/*.html'])
.pipe(gulp.dest('public'));
});
gulp.task('copy-html-production', function () {
return gulp.src(['src/**/*.html'])
.pipe(gulp.dest('dist'));
});
gulp.task('watch', function () {
gulp.watch('src/**/*.styl', ['stylus']);
gulp.watch('src/**/*.html', ['copy-html']);
});
gulp.task('start', ['stylus', 'copy-html', 'watch']);
gulp.task('production', ['stylus-production', 'copy-html-production']);
gulp.task('server', function () {
browserSync({
files: ['public/**/*.html', 'public/**/*.js', 'public/**/*.css'],
port: process.env.PORT || 3000,
reloadOnRestart: false,
logFileChanges: false,
ghostMode: false,
open: false,
ui: false,
server: {
baseDir: 'public',
middleware: [
webpackDevMiddleware(compiler, {
publicPath: webpackConfig.output.publicPath,
stats: { colors: true }
}),
webpackHotMiddleware(compiler)
]
}
});
});