Add --sync-www flag to build script (#10571)
Brian Vaughn committed
Aug 30, 2017 at 09:38 UTC
5ee72dcd821e1706a26a24d27feb9bbb9bde3b90
2 files changed
+32
-13
scripts/rollup/build.js
+4
@@ -18,6 +18,7 @@ const Bundles = require('./bundles');
18
const propertyMangleWhitelist = require('./mangle').propertyMangleWhitelist;
19
const sizes = require('./plugins/sizes-plugin');
20
const Stats = require('./stats');
21
+const syncReactDom = require('./sync').syncReactDom;
22
const syncReactNative = require('./sync').syncReactNative;
23
const Packaging = require('./packaging');
24
const Header = require('./header');
@@ -40,6 +41,7 @@ const requestedBundleNames = (argv._[0] || '')
41
.split(',')
42
.map(type => type.toLowerCase());
43
const syncFbsource = argv['sync-fbsource'];
44
+const syncWww = argv['sync-www'];
45
46
// used for when we property mangle with uglify/gcc
47
const mangleRegex = new RegExp(
@@ -514,6 +516,8 @@ rimraf('build', () => {
516
tasks.push(() =>
517
syncReactNative(join('build', 'react-native'), syncFbsource)
518
);
519
+ } else if (syncWww) {
520
+ tasks.push(() => syncReactDom(join('build', 'facebook-www'), syncWww));
521
}
522
// rather than run concurently, opt to run them serially
523
// this helps improve console/warning/error output
scripts/rollup/sync.js
+28
-13
@@ -5,7 +5,32 @@ const chalk = require('chalk');
5
const resolvePath = require('./utils').resolvePath;
6
7
const DEFAULT_FB_SOURCE_PATH = '~/fbsource/';
8
+const DEFAULT_WWW_PATH = '~/www/';
9
const RELATIVE_RN_PATH = 'xplat/js/react-native-github/Libraries/Renderer/';
10
+const RELATIVE_WWW_PATH = 'html/shared/react/';
11
+
12
+function doSync(buildPath, destPath) {
13
+ console.log(`${chalk.bgYellow.black(' SYNCING ')} React to ${destPath}`);
14
+
15
+ const promise = asyncCopyTo(buildPath, destPath);
16
+ promise.then(() => {
17
+ console.log(`${chalk.bgGreen.black(' SYNCED ')} React to ${destPath}`);
18
+ });
19
+
20
+ return promise;
21
+}
22
+
23
+function syncReactDom(buildPath, wwwPath) {
24
+ wwwPath = typeof wwwPath === 'string' ? wwwPath : DEFAULT_WWW_PATH;
25
+
26
+ if (wwwPath.charAt(wwwPath.length - 1) !== '/') {
27
+ wwwPath += '/';
28
+ }
29
+
30
+ const destPath = resolvePath(wwwPath + RELATIVE_WWW_PATH);
31
+
32
+ return doSync(buildPath, destPath);
33
+}
34
35
function syncReactNative(buildPath, fbSourcePath) {
36
fbSourcePath = typeof fbSourcePath === 'string'
@@ -18,20 +43,10 @@ function syncReactNative(buildPath, fbSourcePath) {
43
44
const destPath = resolvePath(fbSourcePath + RELATIVE_RN_PATH);
45
21
- console.log(
22
- `${chalk.bgYellow.black(' SYNCING ')} ReactNative to ${destPath}`
23
- );
24
-
25
- const promise = asyncCopyTo(buildPath, destPath);
26
- promise.then(() => {
27
- console.log(
28
- `${chalk.bgGreen.black(' SYNCED ')} ReactNative to ${destPath}`
29
- );
30
- });
31
-
32
- return promise;
46
+ return doSync(buildPath, destPath);
47
}
48
49
module.exports = {
36
- syncReactNative: syncReactNative,
50
+ syncReactDom,
51
+ syncReactNative,
52
};