forked from kunadevelopers/bot-trader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.babel.js
More file actions
131 lines (108 loc) · 2.99 KB
/
gulpfile.babel.js
File metadata and controls
131 lines (108 loc) · 2.99 KB
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
import gulp from 'gulp';
import Path from 'path';
import del from 'del';
import gulpWebpack from 'gulp-webpack';
import webpackConfig from './webpack.config.js';
import named from 'vinyl-named';
import sass from 'gulp-sass';
import jsoneditor from 'gulp-json-editor';
import zip from 'gulp-zip';
const manifest = require('./resources/manifest.json');
const PATH = {
SOURCE: Path.join(__dirname, './src'),
TARGET: Path.join(__dirname, './dist')
};
gulp.task('copy:root', copyTask({
source: './app/',
destinations: [
'./dist/firefox',
'./dist/chrome'
],
pattern: '/*',
}));
gulp.task('copy:images', copyTask({
source: './resources/images/',
destinations: [
'./dist/firefox/images',
'./dist/chrome/images'
]
}));
gulp.task('copy:views', copyTask({
source: './resources/views/',
destinations: [
'./dist/firefox/views',
'./dist/chrome/views'
]
}));
gulp.task('manifest:production', () => {
return gulp
.src('./resources/manifest.json')
.pipe(gulp.dest('./dist/firefox', {overwrite: true}))
.pipe(jsoneditor((json) => {
delete json.applications;
return json
}))
.pipe(gulp.dest('./dist/chrome', {overwrite: true}))
});
gulp.task('js', () => {
return gulp
.src([
"./src/popup.jsx",
"./src/pageContent.js",
"./src/background.js"
])
.pipe(named())
.pipe(gulpWebpack(webpackConfig))
.pipe(gulp.dest('./dist/chrome'))
.pipe(gulp.dest('./dist/firefox'));
});
gulp.task('css', () => {
return gulp
.src('./src/Style/popup.scss')
.pipe(
sass({
outputStyle: 'compressed'
}).on('error', sass.logError)
)
.pipe(gulp.dest('./dist/chrome/css'))
.pipe(gulp.dest('./dist/firefox/css'));
});
const staticFiles = ['images', 'views', 'root'];
let copyStrings = staticFiles.map(staticFile => `copy:${staticFile}`);
gulp.task('copy', [
...copyStrings,
'manifest:production'
]);
gulp.task('clean', function clean() {
return del(['./dist/*']);
});
gulp.task('build', ['copy', 'css', 'js']);
gulp.task('copy:watch', function () {
gulp.watch(['./src/*.*'], 'build');
});
gulp.task('zip:chrome', zipTask('chrome'));
gulp.task('zip:firefox', zipTask('firefox'));
gulp.task('zip', ['zip:chrome', 'zip:firefox']);
function copyTask(opts) {
const {
source,
destination,
destinations = [destination],
pattern = '/**/*'
} = opts;
return () => {
let stream = gulp.src(source + pattern, {base: source});
destinations.forEach((destination) => {
stream = stream.pipe(gulp.dest(destination))
});
return stream
}
}
function zipTask(target) {
return () => {
return gulp
.src(`./dist/${target}/**`)
.pipe(zip(`kuna-${target}-${manifest.version}.zip`))
.pipe(gulp.dest('./builds'));
}
}