|
| 1 | +import { join } from 'path' |
| 2 | + |
| 3 | +import * as config from '@nhsuk/frontend-config' |
| 4 | +import { styles, task } from '@nhsuk/frontend-tasks' |
| 5 | +import { glob } from 'glob' |
| 6 | +import gulp from 'gulp' |
| 7 | + |
| 8 | +export const compile = gulp.series( |
| 9 | + /** |
| 10 | + * Transform NHS.UK frontend styles |
| 11 | + */ |
| 12 | + task.name('styles:transform', async () => { |
| 13 | + const modulePaths = await glob('nhsuk/**/*.scss', { |
| 14 | + cwd: join(config.paths.pkg, 'src'), |
| 15 | + nodir: true |
| 16 | + }) |
| 17 | + |
| 18 | + // Apply PostCSS transforms (e.g. vendor prefixes) |
| 19 | + for (const modulePath of modulePaths) { |
| 20 | + await styles.compile(modulePath, { |
| 21 | + srcPath: join(config.paths.pkg, 'src'), |
| 22 | + destPath: join(config.paths.pkg, 'dist'), |
| 23 | + output: { file: modulePath } |
| 24 | + })() |
| 25 | + } |
| 26 | + }), |
| 27 | + |
| 28 | + /** |
| 29 | + * Compile NHS.UK frontend styles bundle |
| 30 | + */ |
| 31 | + task.name( |
| 32 | + 'styles:compile', |
| 33 | + styles.compile('nhsuk/nhsuk.scss', { |
| 34 | + srcPath: join(config.paths.pkg, 'src'), |
| 35 | + destPath: join(config.paths.pkg, 'dist'), |
| 36 | + output: { file: 'nhsuk/nhsuk-frontend.min.css' } |
| 37 | + }) |
| 38 | + ) |
| 39 | +) |
0 commit comments