-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgulpfile.js
More file actions
36 lines (30 loc) · 1.28 KB
/
gulpfile.js
File metadata and controls
36 lines (30 loc) · 1.28 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
const gulp = require("gulp");
const webpack = require('webpack-stream');
const concat = require('gulp-concat');
const userscripts = [
'jvc',
];
for (const userscript of userscripts) {
// JVC USERSCRIPT
gulp.task(`build-userscript-${userscript}-webpack`, () => {
const webpackConfig = require(`./webpack.config.js`);
webpackConfig.output.filename = `${userscript}.user.js`;
return gulp
.src(`./src/${userscript}/index.js`)
.pipe(webpack(webpackConfig))
.on('error',function (err) {
console.error('WEBPACK ERROR', err);
this.emit('end'); // Don't stop the rest of the task
})
.pipe(gulp.dest(`./dist/${userscript}/`))
});
gulp.task(`build-userscript-${userscript}-concat`, () =>
gulp.src([`./src/${userscript}/head.txt`, `./dist/${userscript}/*.user.js`])
.pipe(concat(userscript + '.user.js'))
.pipe(gulp.dest(`./dist/${userscript}/`))
);
gulp.task(`build-userscript-${userscript}`, gulp.series(`build-userscript-${userscript}-webpack`, `build-userscript-${userscript}-concat`));
}
const allTasks = gulp.parallel(...userscripts.map(userscript => `build-userscript-${userscript}`));
// [DEFAULT]
gulp.task('default', allTasks);