-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
285 lines (274 loc) · 7.54 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
var pkg = require('./package.json');
var gulp = require('gulp');
var concat = require('gulp-concat');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var bs = require('browser-sync').create();
var php = require('gulp-connect-php');
//
// var projectPath = {
// src: './resources/src',
// dev: './resources/dev',
// public: './resources/dist'
// };
//
// var entryFile = {
// scss: projectPath.src + '/css/autoload.scss'
// };
//
// // 파일명
// var fileNames = {
// vendor: 'vendor.client',
// jsFile: 'idus.web',
// cssFile: 'idus.web'
// };
//
// // js concat 순서
// var clientJS = [
// !projectPath.src + '/js/ignore/**', // ignore
// projectPath.src + '/js/modules/_init.js', // init script
// projectPath.src + '/js/modules/**.js', // load modules
// projectPath.src + '/js/**.js'
// ];
//
// var vendorJS = [
// './resources/src/vendor/polyfills/dataset.js',
// './node_modules/es6-promise/dist/es6-promise.auto.min.js',
// './node_modules/html5shiv/dist/html5shiv.min.js',
// './node_modules/axios/dist/axios.min.js',
// './node_modules/jquery/dist/jquery.min.js',
// './node_modules/jquery-validation/dist/jquery.validate.min.js',
// './node_modules/jquery-validation/dist/localization/messages_ko.js'
// ];
//
// // DEV TASKS /////////////////////////////////////////////////////////////////////////
//
// sass.compiler = require('node-sass');
//
// gulp.task('buildCss', function() {
// return gulp
// .src('./resources/src/scss/*.scss')
// .pipe(sass().on('error', sass.logError))
// .pipe(gulp.dest('./resources/src/css'));
// });
//
// gulp.task('sass:watch', function() {
// gulp.watch('./sass/**/*.scss', ['sass']);
// });
//
// // projectPath.dev경로 SCSS 처리
// gulp.task('devSCSS', function() {
// return gulp
// .src(entryFile.scss)
// .pipe(sourcemaps.init())
// .pipe(
// sass({
// errLogToConsole: false,
// outputStyle: 'expanded'
// }).on('error', sass.logError)
// )
// .pipe(rename(fileNames.cssFile + '.css'))
// .pipe(
// autoprefixer({
// browsers: ['last 2 versions', 'ie 8', '> 5%'],
// cascade: false
// })
// )
// .pipe(sourcemaps.write('./'))
// .pipe(gulp.dest(projectPath.dev + '/css'))
// .pipe(bs.stream());
// });
//
// // projectPath.dev경로 JS 처리
// gulp.task('devJS', function() {
// return gulp
// .src(clientJS)
// .pipe(sourcemaps.init())
// .pipe(
// concat({
// path: fileNames.jsFile + '.js'
// })
// )
// .pipe(sourcemaps.write('./'))
// .pipe(gulp.dest(projectPath.dev + '/js'))
// .pipe(bs.stream());
// });
//
// // 이미지 스프라이트 옵션
// var spOpt = {
// img: projectPath.src + '/images/sp/**/*.png',
// css: projectPath.src + '/css/sp',
// devImg: projectPath.dev + '/images',
// devCss: projectPath.dev + '/css',
// distImg: projectPath.public + '/images',
// distCss: projectPath.public + '/css',
// bgPath: '../images/sp/',
// addTheme: function(data) {
// var info = data.spritesheet_info;
// var match = info.name.match(/hover--(\w+)/);
// data.theme = match && match[1];
// }
// };
//
// // DEV 이미지 스프라이트 생성
// gulp.task('devSprite', function() {
// var util = spritesmith.util;
// var themeTemplate = util.createTemplate(
// path.join(
// __dirname + '/resources/src/css',
// 'sp-template',
// 'sp-css.hbs'
// ),
// [spOpt.addTheme, util.addPseudoClass]
// );
//
// var opts = {
// spritesmith: function(options, sprite, icons) {
// options.retinaImgPath = spOpt.bgPath + options.imgName;
// options.imgPath = spOpt.bgPath + options.imgName;
// options.cssTemplate = themeTemplate;
// options.cssSpritesheetName = sprite;
// options.padding = 15;
// options.cssName = sprite + '.scss';
// options.cssVarMap = function(sp) {
// sp.name = sp.name;
// };
// return options;
// }
// };
//
// var spriteData = gulp
// .src(spOpt.img)
// .pipe(spritesmith(opts))
// .on('error', function(err) {
// console.log(err);
// });
//
// del([spOpt.devCss + '/*', spOpt.devImg + '/*']);
// spriteData.img.pipe(gulp.dest(spOpt.devImg + '/sp'));
// spriteData.css.pipe(gulp.dest(spOpt.css));
// });
//
// /**
// * browserSync
// * 1. php 실행
// */
// gulp.task('browser-sync', function() {
// php.server({
// port: 8001
// });
// bs.init({
// baseDir: './',
// proxy: '0.0.0.0:8001',
// port: 8080,
// open: true,
// notify: false,
// browser: ['google chrome']
// });
// });
//
// /**
// * 개발용 task (frontend 개발용)
// * 1. browser-sync 실행
// * 2. sass 실행
// * 3. css, js 파일 감시
// */
// // gulp.task(
// // 'default',
// // ['browser-sync', 'devSCSS', 'devJS', 'devSprite'],
// // function() {
// // gulp.watch(projectPath.src + '/**/*.scss', ['devSCSS']);
// // gulp.watch(projectPath.src + '/**/*.js', ['devJS']);
// // gulp.watch(['./**/*.php'], bs.reload);
// // }
// // );
//
// // gulp.task('bs', ['browser-sync'], function() {
// // gulp.watch(['./**/*.php', './**/*.css', './**/*.js'], bs.reload);
// // });
const src = './resources/src';
const dist = './resources/dist';
const path = {
entryScss: `${src}/scss/index.scss`,
watchScss: `${src}/scss/*.scss`,
srcJs: [
`${src}/js/init.js`,
`${src}/js/data.js`,
`${src}/js/util.js`,
`${src}/js/tmpl.js`,
`${src}/js/storage.js`,
`${src}/js/store.js`,
`${src}/js/result-text.js`,
`${src}/js/slack.js`,
`${src}/js/head-count.js`,
`${src}/js/modal.js`,
`${src}/js/clock.js`,
`${src}/js/ju.js`,
`${src}/js/quick-search.js`,
`${src}/js/random-target.js`,
`${src}/js/game.js`
],
distScss: `${dist}/css`,
distJs: `${dist}/js`,
}
/**
* js 빌드
*/
const buildJs = () => {
return gulp
.src(path.srcJs)
.pipe(sourcemaps.init())
.pipe(concat('index.js'))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(path.distJs))
.pipe(bs.stream());
};
/**
* css 빌드
*/
const buildCss = () => {
const scssConfig = {
outputStyle: 'compressed'
};
return gulp
.src(path.entryScss)
.pipe(sourcemaps.init())
.pipe(sass(scssConfig).on('error', sass.logError))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(path.distScss))
.pipe(bs.stream());
}
/**
* watch
*/
const watch = () => {
gulp.watch(path.srcJs, buildJs);
gulp.watch(path.watchScss, buildCss);
};
/**
* php server
*/
const phpServer = () => {
// return false;
return php.server({
port: 8001
});
};
/**
* browserSync
*/
const browserSync = () => {
return bs.init({
baseDir: './',
proxy: '0.0.0.0:8001',
port: 8080,
open: true,
notify: false,
browser: ['google chrome']
});
};
var devServe = gulp.parallel(phpServer, browserSync, watch);
var w = gulp.parallel(watch);
gulp.task('buildJs', buildJs);
gulp.task('devServe', devServe);
gulp.task('w', w);