mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-12 16:47:26 +02:00
Fix CSS tests (#839)
* Fix CSS tests * Revamp * - * fix failing test * add test for minifyCss with fixtures & snapshot * remove unintended addition * simplify the test.css
This commit is contained in:
parent
8cd4b4fca6
commit
4267337fb0
9 changed files with 178 additions and 88 deletions
|
@ -4,9 +4,10 @@
|
|||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const cssnano = require('cssnano');
|
||||
const path = require('path');
|
||||
const escapeStringRegexp = require('escape-string-regexp');
|
||||
const env = require('./env.js');
|
||||
|
||||
// Return the subdirectory path from a reference directory
|
||||
// Example:
|
||||
|
@ -29,6 +30,7 @@ function getLanguage(file, refDir) {
|
|||
const match = regexSubFolder.exec(file);
|
||||
|
||||
// Avoid misinterpreting subdirectory as language
|
||||
const env = require('./env.js');
|
||||
if (match && env.translation.enabled) {
|
||||
const enabledLanguages = env.translation
|
||||
.enabledLanguages()
|
||||
|
@ -40,7 +42,17 @@ function getLanguage(file, refDir) {
|
|||
return null;
|
||||
}
|
||||
|
||||
function minifyCss(cssContent) {
|
||||
return cssnano
|
||||
.process(cssContent, {
|
||||
preset: 'default',
|
||||
zindex: false,
|
||||
})
|
||||
.then(result => result.css);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getSubDir,
|
||||
getLanguage,
|
||||
minifyCss,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue