forked from pixelgrade/pixtypes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
87 lines (74 loc) · 2.03 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
* Load Plugins
*/
var gulp = require( 'gulp' ),
sass = require( 'gulp-ruby-sass' ),
prefix = require( 'gulp-autoprefixer' ),
exec = require( 'gulp-exec' ),
clean = require( 'gulp-clean' ),
zip = require( 'gulp-zip' );
gulp.task( 'styles', function() {
return gulp.src( 'scss/**/*.scss' )
.pipe( sass( {sourcemap: true, style: 'nested'} ) )
.on( 'error', function( e ) {
console.log( e.message );
} )
.pipe( prefix( "last 1 version", "> 1%", "ie 8", "ie 7" ) )
.pipe( gulp.dest( './css/' ) )
.pipe( notify( 'Styles task complete' ) );
} );
gulp.task( 'styles-watch', function() {
return gulp.watch( 'scss/**/*.scss', ['styles'] );
} );
/**
* Create a zip archive out of the cleaned folder and delete the folder
*/
gulp.task( 'zip', ['build'], function() {
return gulp.src( './' )
.pipe( exec( 'cd ./../; rm -rf pixtypes.zip; cd ./build/; zip -r -X ./../pixtypes.zip ./pixtypes; cd ./../; rm -rf build' ) );
} );
/**
* Copy theme folder outside in a build folder, recreate styles before that
*/
gulp.task( 'copy-folder', function() {
return gulp.src( './' )
.pipe( exec( 'rm -Rf ./../build; mkdir -p ./../build/pixtypes; cp -Rf ./* ./../build/pixtypes/' ) );
} );
/**
* Clean the folder of unneeded files and folders
*/
gulp.task( 'build', ['copy-folder'], function() {
// files that should not be present in build zip
files_to_remove = [
'**/codekit-config.json',
'node_modules',
'config.rb',
'gulpfile.js',
'package.json',
'wpgrade-core/vendor/redux2',
'wpgrade-core/features',
'wpgrade-core/tests',
'wpgrade-core/**/*.less',
'wpgrade-core/**/*.scss',
'wpgrade-core/**/*.rb',
'wpgrade-core/**/sass',
'wpgrade-core/**/scss',
'pxg.json',
'build',
'.idea',
'**/*.css.map',
'**/.sass*',
'.sass*',
'**/.git*',
'*.sublime-project',
'.DS_Store',
'**/.DS_Store',
'__MACOSX',
'**/__MACOSX'
];
files_to_remove.forEach( function( e, k ) {
files_to_remove[k] = '../build/pixtypes/' + e;
} );
return gulp.src( files_to_remove, {read: false} )
.pipe( clean( {force: true} ) );
} );