Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build a minified version of each theme file using cssnano #1070

Merged
merged 1 commit into from
Aug 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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