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

Optimize compile-assets.js #1094

Merged
merged 2 commits into from
Dec 8, 2023
Merged
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
9 changes: 2 additions & 7 deletions packages/wallet-sdk/compile-assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,13 @@ const glob = require('glob');
const sass = require('sass');
const { optimize } = require('svgo');

const COPYRIGHT = `
// Copyright (c) 2018-2023 Coinbase, Inc. <https://www.coinbase.com/>
// Licensed under the Apache License, version 2.0
`;

async function main() {
// compile SCSS
const scssFiles = glob.sync(`${__dirname}/src/**/*.scss`);
for (const filePath of scssFiles) {
console.info(`Compiling ${filePath}...`);
const css = sass.renderSync({ file: filePath, outputStyle: 'compressed' }).css.toString('utf8');
const ts = `${COPYRIGHT}\n\nexport default \`${css}\``;
const ts = `export default (() => \`${css}\`)();`;
fs.writeFileSync(filePath.replace(/\.scss$/, '-css.ts'), ts, {
mode: 0o644,
});
Expand All @@ -36,7 +31,7 @@ async function main() {
// so we enable multipass for that to happen
multipass: true,
});
const ts = `${COPYRIGHT}\n\nexport default \`${data}\``;
const ts = `export default \`${data}\``;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will remove svg compiling in a separate pr

fs.writeFileSync(filePath.replace(/\.svg$/, '-svg.ts'), ts, {
mode: 0o644,
});
Expand Down
Loading