-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
70 lines (56 loc) · 1.95 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
61
62
63
64
65
66
67
68
69
70
var gulp = require('gulp');
// Load plugins
var $ = require('gulp-load-plugins')();
var stylelint = require('stylelint');
var reporter = require('postcss-reporter');
var scss = require('postcss-scss');
var sym = require('gulp-sym');
// Where is the app?
var appDir = 'src/';
// Where do you store your Sass files?
var sassDir = appDir + 'scss';
// Which directory should the app compile to?
var targetAppDir = 'dist/';
var targetResourcesDir = targetAppDir;
gulp.task('styles', function () {
gulp.src(sassDir + "/**/*.scss")
// Capture all errors
.pipe($.plumber())
// Lint the scss
.pipe($.postcss([
stylelint(),
reporter({clearMessages: true, throwError: true}),
], {syntax: scss}))
// Compile the scss
.pipe($.sourcemaps.init({loadMaps: true}))
.pipe($.sass({
includePaths: ['node_modules'],
}).on('error', $.sass.logError))
// Add suppost for older browsers
.pipe($.autoprefixer({
browsers: ['last 4 versions'],
cascade: false
}))
// Minify
.pipe($.cssnano())
// Write the files to the public directory
.pipe($.sourcemaps.write('./'))
.pipe(gulp.dest(targetResourcesDir))
.pipe($.size())
});
gulp.task('symlink', function(){
gulp.src(targetAppDir)
.pipe(sym('www.80', { force: true}));
gulp.src(targetAppDir + '/400.css')
.pipe(sym(targetAppDir + '/_resources/css/400.css', { force: true}));
gulp.src(targetAppDir + '/400.css.map')
.pipe(sym(targetAppDir + '/_resources/css/400.css.map', { force: true}));
gulp.src(targetAppDir + '/400.png')
.pipe(sym(targetAppDir + '/_resources/images/400.png', { force: true}));
});
// Default task
gulp.task('default', ['styles', 'symlink']);
// Keep an eye on Sass, JS, for changes...
gulp.task('watch', ['styles'], function () {
gulp.watch(sassDir + '/**/*.scss', ['styles']);
});