-
Notifications
You must be signed in to change notification settings - Fork 72
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
Optimize calc() usage in scss files #1158
base: main
Are you sure you want to change the base?
Changes from all commits
1dcc096
150eb7d
d07d137
2059084
24b3d37
35d11f2
3b0ef5d
c744b56
b9d2042
2a23689
7d3c3f5
9814449
2aee718
c387876
9cc2a25
c69648e
0f5542f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
* under the License. | ||
*/ | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove unnecessary space. |
||
const { execSync } = require('child_process'); | ||
const chalk = require('chalk'); | ||
const path = require('path'); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,8 @@ | |
*/ | ||
|
||
const path = require('path'); | ||
const util = require('util'); | ||
const { writeFile, mkdir } = require('fs/promises'); | ||
const util = require('util') | ||
const { writeFile, mkdir } = require('fs/promises' | ||
Comment on lines
+13
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happened here? Please revert. |
||
const globModule = require('glob'); | ||
|
||
const chalk = require('chalk'); | ||
|
@@ -47,8 +47,8 @@ async function compileScssFiles( | |
|
||
const inputFilenames = await glob(sourcePattern, undefined); | ||
|
||
await Promise.all( | ||
inputFilenames.map(async (inputFilename) => { | ||
await Promise.all | ||
inputFilenames.map(async (inputFilename) => | ||
Comment on lines
+50
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert. |
||
console.log(chalk`{cyan …} Compiling {gray ${inputFilename}}`); | ||
|
||
try { | ||
|
@@ -73,8 +73,7 @@ async function compileScssFiles( | |
|
||
process.exitCode = 1; | ||
return; | ||
} | ||
|
||
|
||
/* OUI -> EUI Aliases */ | ||
try { | ||
const { name } = path.parse(inputFilename); | ||
|
@@ -87,8 +86,8 @@ async function compileScssFiles( | |
true | ||
); | ||
console.log( | ||
chalk`{green ✔} Finished compiling {gray ${inputFilename}} to ${outputFilenames | ||
.map((filename) => chalk.gray(filename)) | ||
chalk`{green ✔} Finished compiling {gray ${inputFilename}} to ${outputFilename | ||
.map((filename) => chalk.gray(filename) | ||
Comment on lines
+89
to
+90
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert |
||
.join(', ')}` | ||
); | ||
} catch (error) { | ||
|
@@ -118,26 +117,33 @@ async function compileScssFile( | |
'.min.css' | ||
); | ||
|
||
|
||
const { | ||
css: renderedCss, | ||
variables: extractedVars, | ||
} = await compileWithVariables(path.resolve(inputFilename)); | ||
|
||
|
||
/* OUI -> EUI Aliases: Modified */ | ||
// const extractedVarTypes = await deriveSassVariableTypes( | ||
const extractedVarTypes_ = await deriveSassVariableTypes( | ||
|
||
/* End of Aliases */ | ||
|
||
extractedVars, | ||
`${packageName}/${outputVarsFilename}`, | ||
outputVarTypesFilename | ||
); | ||
|
||
/* OUI -> EUI Aliases */ | ||
|
||
const declarationMatcher = /^declare\s+module\s+(['"]@opensearch-project\/oui.*?['"])\s*\{/gms; | ||
|
||
let match; | ||
const declarations = []; | ||
|
||
while ((match = declarationMatcher.exec(extractedVarTypes_)) !== null) { | ||
|
||
declarations.push( | ||
`declare module ${match[1].replace( | ||
'@opensearch-project/oui', | ||
|
@@ -149,14 +155,17 @@ async function compileScssFile( | |
); | ||
} | ||
const extractedVarTypes = `${extractedVarTypes_}\n${declarations.join('\n')}`; | ||
|
||
/* End of Aliases */ | ||
|
||
const { css: postprocessedCss } = await postcss(postcssConfiguration).process( | ||
/* OUI -> EUI Aliases: Modified */ | ||
//renderedCss, | ||
|
||
renameToEUI | ||
? renderedCss.toString().replace(/([. '"-])oui/g, '$1eui') | ||
: renderedCss, | ||
|
||
/* End of Aliases */ | ||
{ | ||
from: outputCssFilename, | ||
|
@@ -169,9 +178,11 @@ async function compileScssFile( | |
).process( | ||
/* OUI -> EUI Aliases: Modified */ | ||
//renderedCss, | ||
|
||
renameToEUI | ||
? renderedCss.toString().replace(/([. '"-])oui/g, '$1eui') | ||
: renderedCss, | ||
|
||
/* End of Aliases */ | ||
{ | ||
from: outputCssFilename, | ||
|
@@ -202,6 +213,7 @@ if (require.main === module) { | |
process.exit(1); | ||
} | ||
|
||
|
||
compileScssFiles( | ||
path.join('src', 'theme_*.scss'), | ||
'dist', | ||
|
@@ -210,4 +222,5 @@ if (require.main === module) { | |
console.error(err); | ||
process.exit(2); | ||
}); | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove unnecessary space.