Skip to content

Commit

Permalink
Build a minified version of each theme file using cssnano (#1070)
Browse files Browse the repository at this point in the history
  • Loading branch information
pugnascotia authored Aug 1, 2018
1 parent 46e4d30 commit 9566f74
Show file tree
Hide file tree
Showing 4 changed files with 546 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## [`master`](https://github.com/elastic/eui/tree/master)

- `EuiComboBox` now applies the provided `data-test-subj` to its options list element with the suffix `-optionsList` so you can find a specific combo box instance's options list. This wasn't previously possible because the options list is attached to the body element, not the combo box element. This is in addition to the existing `data-test-subj="comboBoxOptionsList"`. ([#1054](https://github.com/elastic/eui/pull/1054))
- EUI now provides minified versions of the themes' CSS files. ([#1070](https://github.com/elastic/eui/pull/1070))

**Bug fixes**

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"chromedriver": "2.37.0",
"circular-dependency-plugin": "^4.3.0",
"css-loader": "^0.28.7",
"cssnano": "^4.0.5",
"enzyme": "^3.1.0",
"enzyme-adapter-react-16": "^1.0.2",
"enzyme-to-json": "^3.3.0",
Expand Down
16 changes: 16 additions & 0 deletions scripts/compile-scss.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ const writeFile = util.promisify(fs.writeFile);
const mkdir = util.promisify(fs.mkdir);
const glob = util.promisify(globModule);

const postcssConfigurationWithMinification = {
...postcssConfiguration,
plugins: [
...postcssConfiguration.plugins,
require('cssnano')({ preset: 'default' })
],
};

async function compileScssFiles(sourcePattern, destinationDirectory) {
try {
await mkdir(destinationDirectory);
Expand Down Expand Up @@ -49,6 +57,8 @@ async function compileScssFiles(sourcePattern, destinationDirectory) {
}

async function compileScssFile(inputFilename, outputCssFilename, outputVarsFilename) {
const outputCssMinifiedFilename = outputCssFilename.replace(/\.css$/, '.min.css');

const { css: renderedCss, vars: extractedVars } = await sassExtract.render(
{
file: inputFilename,
Expand All @@ -64,8 +74,14 @@ async function compileScssFile(inputFilename, outputCssFilename, outputVarsFilen
to: outputCssFilename,
});

const { css: postprocessedMinifiedCss } = await postcss(postcssConfigurationWithMinification).process(renderedCss, {
from: outputCssFilename,
to: outputCssMinifiedFilename,
});

await Promise.all([
writeFile(outputCssFilename, postprocessedCss),
writeFile(outputCssMinifiedFilename, postprocessedMinifiedCss),
writeFile(outputVarsFilename, JSON.stringify(extractedVars, undefined, 2)),
]);

Expand Down
Loading

0 comments on commit 9566f74

Please sign in to comment.