Skip to content

Commit

Permalink
copy react styles to root of each package before deploying (#37130)
Browse files Browse the repository at this point in the history
  • Loading branch information
kvchari committed Dec 7, 2021
1 parent 0c200f5 commit 37c8e7c
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions build-system/npm-publish/write-package-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ const fastGlob = require('fast-glob');
const marked = require('marked');
const path = require('path');
const posthtml = require('posthtml');
const {copyFile, readFile} = require('fs-extra');
const {getNameWithoutComponentPrefix} = require('../tasks/bento-helpers');
const {getSemver} = require('./utils');
const {log} = require('../common/logging');
const {readFile} = require('fs-extra');
const {stat, writeFile} = require('fs/promises');
const {valid} = require('semver');

Expand Down Expand Up @@ -197,6 +197,26 @@ async function writeReactJs() {
}
}

/**
* todo(kvchari): temporarily copy styles to root of each package to support importing styles from root
* Remove when we begin properly proxying style imports.
* See issue from more information:
* @return {Promise<void>}
*/
async function copyCssToRoot() {
try {
const extDir = path.join('extension', extension, '1.0');
const preactCssDist = path.join(extDir, 'dist', 'styles.css');
const preactCssRoot = path.join(extDir, 'styles.css');
await copyFile(preactCssDist, preactCssRoot);
log('Copied', preactCssDist, 'to npm package root');
} catch (e) {
log(e);
process.exitCode = 1;
return;
}
}

/**
* Main
* @return {Promise<void>}
Expand All @@ -205,8 +225,9 @@ async function main() {
if (await shouldSkip()) {
return;
}
writePackageJson();
writeReactJs();
await writePackageJson();
await writeReactJs();
await copyCssToRoot();
}

main();

0 comments on commit 37c8e7c

Please sign in to comment.