Skip to content

Commit

Permalink
Update review app to use pre-built govuk-frontend modules
Browse files Browse the repository at this point in the history
Rollup build is not necessary when `all.bundle.min.mjs` is already built
  • Loading branch information
colinrotherham committed Jun 23, 2023
1 parent e881f41 commit 1bd3aba
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 79 deletions.
2 changes: 0 additions & 2 deletions docs/contributing/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ This task will:

This task will:

- check JavaScript code quality via ESLint (`npm run lint:js`) (using JavaScript Standard Style)
- compile JavaScript to Immediately Invoked Function Expression (IIFE) into `./packages/govuk-frontend-review/dist/javascripts`
- compile JavaScript documentation into `./packages/govuk-frontend-review/dist/docs/jsdoc`

## Review app only
Expand Down
12 changes: 10 additions & 2 deletions packages/govuk-frontend-review/browsersync.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ module.exports = {

// Files to watch for auto reload
files: [
join(paths.app, 'dist/javascripts/**/*.mjs'),
join(paths.app, 'dist/stylesheets/**/*.css'),
join(paths.app, 'src/views/**/*.njk'),

packageTypeToPath('govuk-frontend', {
modulePath: 'all.bundle.min.mjs',
moduleRoot: paths.app
}),

packageTypeToPath('govuk-frontend', {
modulePath: '**/*.njk',
moduleRoot: paths.app
Expand All @@ -36,7 +41,10 @@ module.exports = {
serveStatic: [
{
route: '/javascripts',
dir: join(paths.app, 'dist/javascripts')
dir: packageTypeToPath('govuk-frontend', {
modulePath: '/',
moduleRoot: paths.app
})
},
{
route: '/stylesheets',
Expand Down
2 changes: 1 addition & 1 deletion packages/govuk-frontend-review/nodemon.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"../../shared/lib",
"../../shared/stats"
],
"ignore": ["./src/javascripts/**", "**/*.test.*"],
"ignore": ["**/*.test.*"],
"events": {
"restart": "browser-sync reload --config browsersync.config.js"
},
Expand Down
45 changes: 0 additions & 45 deletions packages/govuk-frontend-review/rollup.config.mjs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ const router = express.Router()
* Add middleware to serve static assets
*/

router.use('/assets', express.static(packageTypeToPath('govuk-frontend', { modulePath: 'assets', moduleRoot: paths.app })))
router.use('/javascripts', express.static(join(paths.app, 'dist/javascripts')))
router.use('/', express.static(packageTypeToPath('govuk-frontend', { modulePath: '/', moduleRoot: paths.app })))
router.use('/stylesheets', express.static(join(paths.app, 'dist/stylesheets')))

export default router
1 change: 0 additions & 1 deletion packages/govuk-frontend-review/src/javascripts/all.mjs

This file was deleted.

17 changes: 2 additions & 15 deletions packages/govuk-frontend-review/tasks/scripts.mjs
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
import { join } from 'path'

import { npm, scripts, task } from 'govuk-frontend-tasks'
import { npm } from 'govuk-frontend-tasks'
import gulp from 'gulp'

/**
* JavaScripts task (for watch)
* Compilation, documentation
* Documentation
*
* @type {import('govuk-frontend-tasks').TaskFunction}
*/
export const compile = (options) => gulp.series(
task.name("compile:js 'iife'", () =>
scripts.compile('all.mjs', {
...options,

srcPath: join(options.srcPath, 'javascripts'),
destPath: join(options.destPath, 'javascripts'),
configPath: join(options.basePath, 'rollup.config.mjs')
})
),

// Build JSDoc for /docs/javascript
npm.script('build:jsdoc', [], options)
)
12 changes: 1 addition & 11 deletions packages/govuk-frontend-review/tasks/watch.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,12 @@ export const watch = (options) => gulp.parallel(
], styles(options))
),

/**
* JavaScripts lint watcher
*/
task.name('lint:js watch', () =>
gulp.watch([
`${slash(paths.app)}/src/javascripts/**/*.mjs`
], npm.script('lint:js:cli', [slash(join(options.workspace, '**/*.{cjs,js,md,mjs}'))]))
),

/**
* JavaScripts build watcher
*/
task.name("compile:js 'iife' watch", () =>
task.name('compile:js watch', () =>
gulp.watch([
`${slash(paths.root)}/typedoc.config.js`,
`${slash(paths.app)}/src/javascripts/**/*.mjs`,
`${slash(paths.package)}/dist/govuk/**/*.mjs`
], scripts(options))
)
Expand Down

0 comments on commit 1bd3aba

Please sign in to comment.