Skip to content

Commit

Permalink
Prevent version number update during development
Browse files Browse the repository at this point in the history
  • Loading branch information
querkmachine authored and colinrotherham committed Mar 31, 2023
1 parent 6717ed1 commit 0b182c6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
23 changes: 13 additions & 10 deletions postcss.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import unopacity from 'postcss-unopacity'
import unrgba from 'postcss-unrgba'

import { pkg } from './config/index.js'
import { isDev } from './tasks/helpers/task-arguments.mjs'

/**
* PostCSS config
Expand Down Expand Up @@ -61,17 +62,19 @@ export default ({ from = '', to = '', env = 'production' }) => {
}

// Add GOV.UK Frontend release version
config.plugins.push({
postcssPlugin: 'govuk-frontend-version',
Declaration: {
// Find CSS declaration for version, update value
// https://github.com/postcss/postcss/blob/main/docs/writing-a-plugin.md
// https://postcss.org/api/#declaration
'--govuk-frontend-version': (decl) => {
decl.value = `"${pkg.version}"`
if (!isDev) {
config.plugins.push({
postcssPlugin: 'govuk-frontend-version',
Declaration: {
// Find CSS declaration for version, update value
// https://github.com/postcss/postcss/blob/main/docs/writing-a-plugin.md
// https://postcss.org/api/#declaration
'--govuk-frontend-version': (decl) => {
decl.value = `"${pkg.version}"`
}
}
}
})
})
}

// Always minify CSS
if (config.syntax !== scss) {
Expand Down
11 changes: 7 additions & 4 deletions tasks/scripts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { pkg } from '../config/index.js'
import { getListing } from '../lib/file-helper.js'
import { componentPathToModuleName } from '../lib/helper-functions.js'

import { isDev } from './helpers/task-arguments.mjs'
import { assets } from './index.mjs'

/**
Expand Down Expand Up @@ -41,14 +42,16 @@ export async function compileJavaScript ([modulePath, { srcPath, destPath, fileP
const moduleDestPath = join(destPath, filePath ? filePath(parse(modulePath)) : modulePath)

// Rollup plugins
const plugins = [
const plugins = []

if (!isDev) {
// Add GOV.UK Frontend release version
// @ts-expect-error "This expression is not callable" due to incorrect types
replace({
plugins.push(replace({
include: join(srcPath, 'common/govuk-frontend-version.mjs'),
values: { development: pkg.version }
})
]
}))
}

// Option 1: Rollup bundle set (multiple files)
// - Module imports are preserved, not concatenated
Expand Down

0 comments on commit 0b182c6

Please sign in to comment.