forked from inakianduaga/showcar-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
155 lines (134 loc) · 5.6 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
const gulp = require('gulp');
const scgulp = require('showcar-gulp')(gulp);
// Don't put in separate task. Runs async on each gulp task
const pkg = require('showcar-gulp/package.json');
const updateNotifier = require('update-notifier');
updateNotifier({
pkg,
updateCheckInterval: 1 //check each time
}).notify({ defer: false, isGlobal: false });
gulp.task('eslint', scgulp.eslint({
files: 'src/**/*.js'
}));
gulp.task('js', gulp.series('eslint', scgulp.js({
entry: 'src/showcar-ui.js',
out: 'dist/showcar-ui.js',
})));
gulp.task('icons', gulp.series('eslint', scgulp.js({
entry: 'src/js/showcar-icons.js',
out: 'dist/showcar-icons.js',
})));
gulp.task('tracking', gulp.series('eslint', scgulp.js({
entry: 'src/js/showcar-tracking.js',
out: 'dist/showcar-tracking.js',
})));
gulp.task('stylelint', scgulp.stylelint({
files: 'src/**/*.scss'
}));
gulp.task('scss', gulp.series('stylelint', scgulp.scss({
entry: 'src/showcar-ui.scss',
out: 'dist/showcar-ui.css',
})));
gulp.task('clean', scgulp.clean({
files: ['dist/**/*']
}));
gulp.task('serve', scgulp.serve({
dir: 'dist'
}));
gulp.task('copy:fragments', done => {
gulp.src('src/html/showcar-ui-fragment.html').pipe(gulp.dest('dist/'));
gulp.src('src/html/showcar-ui-standalone-fragment.html').pipe(gulp.dest('dist/'));
gulp.src('src/html/showcar-ui-toggled-fragment.html').pipe(gulp.dest('dist/'));
gulp.src('src/html/showcar-ui-toggled-test-fragment.html').pipe(gulp.dest('dist/'));
gulp.src('src/html/optimizely-*.html').pipe(gulp.dest('dist/'));
done();
});
const fs = require('fs');
const UglifyJS = require('uglify-js');
const readFile = filename => fs.readFileSync(filename, 'utf-8');
const readJsFile = filename => UglifyJS.minify(readFile(filename)).code;
const stringReplace = require('gulp-string-replace');
var replaceOptions = {
logs: {
enabled: false
}
};
gulp.task('replace', done => {
gulp.src(['src/html/index.html', 'src/html/index-standalone.html', 'docs/helpers/polyfills.js'])
.pipe(stringReplace('@@POLYFILL_DOCUMENT_REGISTER_ELEMENT', readFile('node_modules/document-register-element/build/document-register-element.js'), replaceOptions))
.pipe(stringReplace('@@POLYFILL_DOM4', readFile('node_modules/dom4/build/dom4.js'), replaceOptions))
.pipe(stringReplace('@@POLYFILL_ARRAY', readJsFile('src/js/polyfills/array.js'), replaceOptions))
.pipe(stringReplace('@@POLYFILL_STRING', readJsFile('src/js/polyfills/string.js'), replaceOptions))
.pipe(stringReplace('@@POLYFILL_OBJECT', readJsFile('src/js/polyfills/object.js'), replaceOptions))
.pipe(stringReplace('@@POLYFILL_PROMISE', readJsFile('node_modules/promiz/promiz.min.js'), replaceOptions))
.pipe(stringReplace('@@POLYFILL_FETCH', readJsFile('node_modules/whatwg-fetch/fetch.js'), replaceOptions))
.pipe(stringReplace('@@POLYFILL_URL_SEARCH_PARAMS', readJsFile('node_modules/url-search-params-polyfill/index.js'), replaceOptions))
.pipe(stringReplace('@@SCRIPT_ERROR_COLLECTOR', readJsFile('src/js/inline-js/js-error-collector.js'), replaceOptions))
.pipe(stringReplace('@@SCRIPT_FONT_LOADER', readJsFile('src/js/inline-js/font-loader.js'), replaceOptions))
.pipe(gulp.dest('dist/'));
done();
});
gulp.task('set-dev', () => {
scgulp.config.devmode = true;
});
gulp.task('docs:generate', (done) => {
require('./docs/tasks/generateJson')();
require('./docs/tasks/generateHtml')();
done();
});
const serveDocs = require('./docs/tasks/docs');
gulp.task('build', gulp.series('js', 'icons', 'tracking', 'scss', 'copy:fragments', 'replace'));
gulp.task('docs:serve', done => {
serveDocs(gulp);
done();
});
gulp.task('docs:edit', gulp.series('build'), () => {serveDocs(gulp);});
gulp.task('docs:watch', gulp.series('build'), () => {serveDocs(gulp);});
gulp.task('default', gulp.series('docs:watch'));
const testingParams = {
files: ['.quixoteconf.js'],
preprocessors: {
'.quixoteconf.js': ['webpack', 'sourcemap']
},
proxies: {
'/': 'http://localhost:3000/',
}
};
gulp.task('test', gulp.series('docs:serve', scgulp.karma(
Object.assign({}, testingParams, {
browsers: ['Firefox', 'Chrome', 'Safari']
}))
));
gulp.task('test:fast', gulp.series('docs:serve', scgulp.karma(
Object.assign({}, testingParams, {
browsers: ['Chrome']
}))
));
gulp.task('test:bs', gulp.series('docs:serve', scgulp.karma(
Object.assign({}, testingParams, {
browserStack: {
build: new Date().toLocaleString('de-DE', {
hour12: false,
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit'
}),
project: 'Showcar-ui',
},
// browsers: ['bs_safari_mac', 'bs_chrome_win', 'bs_firefox_win', 'bs_edge_win', 'bs_ie11_win', 'bs_iphone6s', 'bs_iphone7'],
browsers: ['bs_chrome_win', 'bs_firefox_win', 'bs_edge_win', 'bs_ie11_win'],
}))
));
gulp.task('test:travis', gulp.series('docs:serve', scgulp.karma(
Object.assign({}, testingParams, {
browserStack: {
project: 'Showcar-ui',
},
// browsers: ['bs_safari_mac', 'bs_chrome_win', 'bs_firefox_win', 'bs_edge_win', 'bs_ie11_win', 'bs_iphone6s', 'bs_iphone7'],
// temporary removed iphones
// browsers: ['bs_safari_mac', 'bs_chrome_win', 'bs_firefox_win', 'bs_edge_win', 'bs_ie11_win'],
browsers: ['bs_chrome_win', 'bs_firefox_win', 'bs_edge_win', 'bs_ie11_win'], //temporary remove safari
// browsers: ['bs_chrome_win'], //only test on chrome
}))
));