|
| 1 | +import chug from 'gulp-chug'; |
| 2 | +import gulp from 'gulp'; |
| 3 | +import upath from 'path'; |
| 4 | +import yargs from 'yargs'; |
| 5 | + |
| 6 | +const { argv } = yargs |
| 7 | + .options({ |
| 8 | + rootPath: { |
| 9 | + description: '<path> path to web assets directory', |
| 10 | + type: 'string', |
| 11 | + requiresArg: true, |
| 12 | + required: false, |
| 13 | + }, |
| 14 | + vendorPath: { |
| 15 | + description: '<path> path to vendor directory', |
| 16 | + type: 'string', |
| 17 | + requiresArg: true, |
| 18 | + required: false, |
| 19 | + }, |
| 20 | + nodeModulesPath: { |
| 21 | + description: '<path> path to node_modules directory', |
| 22 | + type: 'string', |
| 23 | + requiresArg: true, |
| 24 | + required: false, |
| 25 | + }, |
| 26 | + }); |
| 27 | + |
| 28 | +const config = [ |
| 29 | + '--rootPath', |
| 30 | + argv.rootPath || '../../../../../../../tests/Application/web/assets', |
| 31 | + ...(argv.vendorPath ? [ |
| 32 | + '--vendorPath', |
| 33 | + upath.joinSafe(argv.vendorPath, 'sylius/sylius/src/Sylius/Bundle'), |
| 34 | + ] : []), |
| 35 | + '--nodeModulesPath', |
| 36 | + argv.nodeModulesPath || '../../../../../../../tests/Application/node_modules', |
| 37 | +]; |
| 38 | + |
| 39 | +export const buildAdmin = function buildAdmin() { |
| 40 | + return gulp.src('../../vendor/sylius/sylius/src/Sylius/Bundle/AdminBundle/gulpfile.babel.js', { read: false }) |
| 41 | + .pipe(chug({ args: config })); |
| 42 | +}; |
| 43 | +buildAdmin.description = 'Build admin assets.'; |
| 44 | + |
| 45 | +export const watchAdmin = function watchAdmin() { |
| 46 | + return gulp.src('../../vendor/sylius/sylius/src/Sylius/Bundle/AdminBundle/gulpfile.babel.js', { read: false }) |
| 47 | + .pipe(chug({ args: config, tasks: 'watch' })); |
| 48 | +}; |
| 49 | +watchAdmin.description = 'Watch admin asset sources and rebuild on changes.'; |
| 50 | + |
| 51 | +export const buildShop = function buildShop() { |
| 52 | + return gulp.src('../../vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/gulpfile.babel.js', { read: false }) |
| 53 | + .pipe(chug({ args: config })); |
| 54 | +}; |
| 55 | +buildShop.description = 'Build shop assets.'; |
| 56 | + |
| 57 | +export const watchShop = function watchShop() { |
| 58 | + return gulp.src('../../vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/gulpfile.babel.js', { read: false }) |
| 59 | + .pipe(chug({ args: config, tasks: 'watch' })); |
| 60 | +}; |
| 61 | +watchShop.description = 'Watch shop asset sources and rebuild on changes.'; |
| 62 | + |
| 63 | +export const build = gulp.parallel(buildAdmin, buildShop); |
| 64 | +build.description = 'Build assets.'; |
| 65 | + |
| 66 | +gulp.task('admin', buildAdmin); |
| 67 | +gulp.task('admin-watch', watchAdmin); |
| 68 | +gulp.task('shop', buildShop); |
| 69 | +gulp.task('shop-watch', watchShop); |
| 70 | + |
| 71 | +export default build; |
0 commit comments