-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
177 lines (171 loc) · 4.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
const gulp = require('gulp');
const sass = require('gulp-sass');
const sassGlob = require('gulp-sass-glob');
const cssmin = require('gulp-cssmin');
const plumber = require('gulp-plumber');
const notify = require('gulp-notify');
const concat = require('gulp-concat');
const autoprefixer = require('gulp-autoprefixer');
// const gih = require("gulp-include-html");
const imagemin = require('gulp-imagemin');
const mergeStream = require('merge-stream');
const jshint = require('gulp-jshint');
const uglify = require('gulp-uglify');
const babel = require('gulp-babel');
const browserSync = require('browser-sync').create();
const rename = require('gulp-rename');
const sftp = require('gulp-sftp-up4');
const sourcemaps = require('gulp-sourcemaps');
const changed = require('gulp-changed');
//WordPressテーマの変換
function convert_wp_theme() {
const in_dir = './wp-theme/';
const out_dir = './Dist/wp-theme/';
const options = (dist_path = '') => {
return {
host: 'www6.conoha.ne.jp',
port: 8022,
user: 'c0704253',
remotePlatform: 'unix',
remotePath: '/home/c0704253/public_html/step.nextlav.xyz/wp-content/themes/match_plate/'+dist_path,
key: '/Users/lavp/.ssh/conoha.pem'
}
}
return mergeStream(
// in style css
gulp
.src(in_dir + '/style/**/*.scss')
.pipe(changed(out_dir + 'style'))
.pipe(sourcemaps.init())
.pipe(
plumber({ errorHandler: notify.onError('Error: <%= error.message %>') })
)
.pipe(sass())
.pipe(autoprefixer({ grid: 'autoplace' }))
.pipe(cssmin())
.pipe(sourcemaps.write())
.pipe(gulp.dest(out_dir + 'style'))
.pipe(sftp(options('style'))),
// in root css
gulp
.src(in_dir + 'style.css')
.pipe(changed(out_dir))
.pipe(sourcemaps.init())
.pipe(
plumber({ errorHandler: notify.onError('Error: <%= error.message %>') })
)
.pipe(sass())
.pipe(autoprefixer({ grid: 'autoplace' }))
.pipe(sourcemaps.write())
.pipe(gulp.dest(out_dir))
.pipe(sftp(options(''))),
//js
gulp
.src(in_dir + '/js/**/*.js')
.pipe(changed(out_dir + 'js'))
.pipe(sourcemaps.init())
.pipe(jshint())
.pipe(babel({
"presets": ["@babel/preset-env"]
}))
.pipe(uglify())
.pipe(sourcemaps.write())
.pipe(gulp.dest(out_dir + 'js'))
.pipe(sftp(options('js'))),
// images
gulp
.src(in_dir + '/images/**/*')
.pipe(changed(out_dir + 'images'))
.pipe(imagemin())
.pipe(gulp.dest(out_dir + 'images'))
.pipe(sftp(options('images'))),
//root php
gulp.src(in_dir + '*.php')
.pipe(changed(out_dir))
.pipe(sourcemaps.init())
.pipe(sourcemaps.write())
.pipe(gulp.dest(out_dir))
.pipe(sftp(options(''))),
//mpa parts
gulp.src(in_dir + '/mpa/*.php')
.pipe(changed(out_dir + '/mpa'))
.pipe(sourcemaps.init())
.pipe(sourcemaps.write())
.pipe(gulp.dest(out_dir + '/mpa'))
.pipe(sftp(options('mpa')))
);
}
//ar_scan_appの変換
function convert_ar_scan_app() {
const in_dir = './ar_scan_app/';
const out_dir = './Dist/ar/';
const options = (dist_path = '') => {
return {
host: 'www6.conoha.ne.jp',
port: 8022,
user: 'c0704253',
remotePlatform: 'unix',
remotePath: '/home/c0704253/public_html/step.nextlav.xyz/ar/'+dist_path,
key: '/Users/lavp/.ssh/conoha.pem'
}
};
return mergeStream(
// style
gulp
.src(in_dir + '/style/**/*.scss')
.pipe(changed(out_dir + 'style'))
.pipe(sourcemaps.init())
.pipe(
plumber({ errorHandler: notify.onError('Error: <%= error.message %>') })
)
.pipe(sass())
.pipe(autoprefixer({ grid: 'autoplace' }))
.pipe(cssmin())
.pipe(sourcemaps.write())
.pipe(gulp.dest(out_dir + 'style'))
.pipe(sftp(options('style'))),
//js
gulp
.src(in_dir + '/js/**/*.js')
.pipe(changed(out_dir + 'js'))
.pipe(sourcemaps.init())
.pipe(jshint())
.pipe(babel({
"presets": ["@babel/preset-env"]
}))
.pipe(uglify())
.pipe(sourcemaps.write())
.pipe(gulp.dest(out_dir + 'js'))
.pipe(sftp(options('js'))),
// assets
gulp.src(in_dir + '/assets/**/*')
.pipe(changed(out_dir + 'assets'))
.pipe(gulp.dest(out_dir + 'assets'))
.pipe(sftp(options('assets'))),
//root php
gulp.src(in_dir + '*.php')
.pipe(changed(out_dir))
.pipe(sourcemaps.init())
.pipe(sourcemaps.write())
.pipe(gulp.dest(out_dir))
.pipe(sftp(options(''))),
//ui parts
gulp.src(in_dir + '/ui_parts/*.php')
.pipe(changed(out_dir + '/ui_parts'))
.pipe(sourcemaps.init())
.pipe(sourcemaps.write())
.pipe(gulp.dest(out_dir + '/ui_parts'))
.pipe(sftp(options('ui_parts')))
);
}
function watch() {
//変換処理
gulp.watch('./wp-theme/**/*', convert_wp_theme);
gulp.watch('./ar_scan_app/**/*', convert_ar_scan_app);
}
exports.default = gulp.series(
convert_wp_theme,
convert_ar_scan_app,
watch
);
//exports.default = gulp.series(upload_wp_theme,upload_ar_scan_app);