Skip to content

Commit

Permalink
Autoprefix generated CSS
Browse files Browse the repository at this point in the history
Autoprefix CSS using postcss and autoprefixer. This will fix the display of the close button’s chevron in IE9 (which requires `-ms-transform`) and probably some other stuff too.

This uses the same browserlist as we have in GOV.UK Frontend.
  • Loading branch information
36degrees committed Aug 9, 2018
1 parent 2f47897 commit 44fac9d
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 6 deletions.
7 changes: 7 additions & 0 deletions lib/metalsmith.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const permalinks = require('metalsmith-permalinks') // apply a permalin
const canonical = require('metalsmith-canonical') // add a canonical url property to pages

const sass = require('metalsmith-sass') // convert Sass files to CSS using LibSass
const postcss = require('metalsmith-postcss')

const rollup = require('metalsmith-rollup') // used to build GOV.UK Frontend JavaScript
const resolve = require('rollup-plugin-node-resolve') // rollup plugin to resolve node_modules
Expand Down Expand Up @@ -65,6 +66,12 @@ module.exports = metalsmith(__dirname) // __dirname defined by node.js: name of
includePaths: ['node_modules'] // an array of paths that sass can look in when attempt to resolve @import declarations
}))

.use(postcss({
plugins: {
'autoprefixer': {}
}
}))

// copy static assets from node_modules/@govukfrontend
.use(assets({
source: '../' + paths.govukfrontend + 'assets/',
Expand Down
123 changes: 118 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@
]
},
"dependencies": {
"autoprefixer": "^9.1.0",
"clipboard": "^2.0.0",
"govuk-frontend": "^1.2.0",
"gray-matter": "^4.0.1",
"html5shiv": "^3.7.3",
"jquery": "^1.12.4",
"lunr": "^2.3.1",
"metalsmith-postcss": "^4.2.0",
"modernizr": "^3.6.0",
"sass-export": "^1.0.2"
},
Expand Down Expand Up @@ -76,5 +78,11 @@
},
"jest": {
"preset": "jest-puppeteer"
}
},
"browserslist": [
"last 2 versions",

This comment has been minimized.

Copy link
@Nooshu

Nooshu Aug 9, 2018

Is it worth changing this line since it says "We support the last 2 versions of every browser"? More info here

This comment has been minimized.

Copy link
@NickColley

NickColley Aug 9, 2018

Contributor

sounds good we would want to do this consistently, can you please raise an issue on GOV.UK Frontend?

I think this is less risky since we only currently use browserslist for CSS

"ie 8",
"ie 9",
"iOS 9"
]
}

0 comments on commit 44fac9d

Please sign in to comment.