Skip to content

Commit 13a69bd

Browse files
committed
add logic to make prod and dev playroom integration more consistent
1 parent 58ab8e2 commit 13a69bd

File tree

5 files changed

+64
-10
lines changed

5 files changed

+64
-10
lines changed

polaris-react/src/components/Badge/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export function getDefaultAccessibilityLabel(
77
progress?: Progress,
88
status?: Status,
99
): string {
10-
console.log(progress, status);
1110
let progressLabel = '';
1211
let statusLabel = '';
1312

polaris.shopify.com/next.config.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,16 @@ const nextConfig = {
1010
},
1111
async rewrites() {
1212
return [
13-
{
14-
source: '/sandbox',
15-
destination: '/sandbox/index.html',
16-
},
13+
// We want to rewrite the sandbox route in production
14+
// to point at the public directory that our playroom assets are built to
15+
...(process.env.NODE_ENV === 'production'
16+
? [
17+
{
18+
source: '/sandbox',
19+
destination: '/sandbox/index.html',
20+
},
21+
]
22+
: []),
1723
];
1824
},
1925
async headers() {
@@ -39,6 +45,17 @@ const nextConfig = {
3945

4046
async redirects() {
4147
return [
48+
// We run a redirect to port 9000 for non prod environments
49+
// as playroom files aren't built to the public directory in dev mode.
50+
...(process.env.NODE_ENV !== 'production'
51+
? [
52+
{
53+
source: '/sandbox',
54+
destination: 'http://localhost:9000',
55+
permanent: false,
56+
},
57+
]
58+
: []),
4259
{
4360
source: '/components/get-started',
4461
destination: '/components',

polaris.shopify.com/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"scripts": {
66
"build": "yarn playroom:build && next build",
7-
"dev": "open http://localhost:3000 && next dev",
7+
"dev": "concurrently \"open http://localhost:3000 && next dev\" \"npm:playroom:start\"",
88
"start": "next start",
99
"lint": "run-p lint:*",
1010
"lint:js": "TIMING=1 eslint --cache .",
@@ -40,6 +40,7 @@
4040
"@types/node": "17.0.21",
4141
"@types/prismjs": "^1.26.0",
4242
"@types/react": "*",
43+
"concurrently": "ˆ7.3.0",
4344
"eslint-config-next": "12.1.0",
4445
"eslint": "8.10.0",
4546
"execa": "^6.1.0",

polaris.shopify.com/playroom.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = {
1616
//scope: "./playroom/useScope.js",
1717
widths: breakpointsConfig,
1818
port: 9000,
19-
openBrowser: true,
19+
openBrowser: false,
2020
paramType: 'hash', // default is 'hash'
2121
//exampleCode: `
2222
// <Button>

yarn.lock

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7825,6 +7825,21 @@ concat-stream@^1.5.0:
78257825
readable-stream "^2.2.2"
78267826
typedarray "^0.0.6"
78277827

7828+
concurrently@ˆ7.3.0:
7829+
version "7.3.0"
7830+
resolved "https://registry.yarnpkg.com/concurrently/-/concurrently-7.3.0.tgz#eb45cdbc8df43da195f619aba218a980cae49184"
7831+
integrity sha512-IiDwm+8DOcFEInca494A8V402tNTQlJaYq78RF2rijOrKEk/AOHTxhN4U1cp7GYKYX5Q6Ymh1dLTBlzIMN0ikA==
7832+
dependencies:
7833+
chalk "^4.1.0"
7834+
date-fns "^2.16.1"
7835+
lodash "^4.17.21"
7836+
rxjs "^7.0.0"
7837+
shell-quote "^1.7.3"
7838+
spawn-command "^0.0.2-1"
7839+
supports-color "^8.1.0"
7840+
tree-kill "^1.2.2"
7841+
yargs "^17.3.1"
7842+
78287843
configstore@^3.0.0:
78297844
version "3.1.5"
78307845
resolved "https://registry.yarnpkg.com/configstore/-/configstore-3.1.5.tgz#e9af331fadc14dabd544d3e7e76dc446a09a530f"
@@ -8411,6 +8426,11 @@ [email protected]:
84118426
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.28.0.tgz#9570d656f5fc13143e50c975a3b6bbeb46cd08b2"
84128427
integrity sha512-8d35hViGYx/QH0icHYCeLmsLmMUheMmTyV9Fcm6gvNwdw31yXXH+O85sOBJ+OLnLQMKZowvpKb6FgMIQjcpvQw==
84138428

8429+
date-fns@^2.16.1:
8430+
version "2.29.2"
8431+
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.29.2.tgz#0d4b3d0f3dff0f920820a070920f0d9662c51931"
8432+
integrity sha512-0VNbwmWJDS/G3ySwFSJA3ayhbURMTJLtwM2DTxf9CWondCnh6DTNlO9JgRSq6ibf4eD0lfMJNBxUdEAHHix+bA==
8433+
84148434
84158435
version "1.11.2"
84168436
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.2.tgz#fa0f5223ef0d6724b3d8327134890cfe3d72fbe5"
@@ -18376,6 +18396,13 @@ rxjs@^6.4.0:
1837618396
dependencies:
1837718397
tslib "^1.9.0"
1837818398

18399+
rxjs@^7.0.0:
18400+
version "7.5.6"
18401+
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.5.6.tgz#0446577557862afd6903517ce7cae79ecb9662bc"
18402+
integrity sha512-dnyv2/YsXhnm461G+R/Pe5bWP41Nm6LBXEYWI6eiFP4fiwx6WRI/CD0zbdVAudd9xwLEF2IDcKXLHit0FYjUzw==
18403+
dependencies:
18404+
tslib "^2.1.0"
18405+
1837918406
sade@^1.7.3:
1838018407
version "1.8.1"
1838118408
resolved "https://registry.yarnpkg.com/sade/-/sade-1.8.1.tgz#0a78e81d658d394887be57d2a409bf703a3b2701"
@@ -18765,7 +18792,7 @@ shebang-regex@^3.0.0:
1876518792
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172"
1876618793
integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==
1876718794

18768-
shell-quote@^1.6.1:
18795+
shell-quote@^1.6.1, shell-quote@^1.7.3:
1876918796
version "1.7.3"
1877018797
resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.7.3.tgz#aa40edac170445b9a431e17bb62c0b881b9c4123"
1877118798
integrity sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw==
@@ -19063,6 +19090,11 @@ space-separated-tokens@^2.0.0:
1906319090
resolved "https://registry.yarnpkg.com/space-separated-tokens/-/space-separated-tokens-2.0.1.tgz#43193cec4fb858a2ce934b7f98b7f2c18107098b"
1906419091
integrity sha512-ekwEbFp5aqSPKaqeY1PGrlGQxPNaq+Cnx4+bE2D8sciBQrHpbwoBbawqTN2+6jPs9IdWxxiUcN0K2pkczD3zmw==
1906519092

19093+
spawn-command@^0.0.2-1:
19094+
version "0.0.2-1"
19095+
resolved "https://registry.yarnpkg.com/spawn-command/-/spawn-command-0.0.2-1.tgz#62f5e9466981c1b796dc5929937e11c9c6921bd0"
19096+
integrity sha512-n98l9E2RMSJ9ON1AKisHzz7V42VDiBQGY6PB1BwRglz99wpVsSuGzQ+jOi6lFXBGVTCrRpltvjm+/XA+tpeJrg==
19097+
1906619098
spawndamnit@^2.0.0:
1906719099
version "2.0.0"
1906819100
resolved "https://registry.yarnpkg.com/spawndamnit/-/spawndamnit-2.0.0.tgz#9f762ac5c3476abb994b42ad592b5ad22bb4b0ad"
@@ -19693,7 +19725,7 @@ supports-color@^7.0.0, supports-color@^7.1.0:
1969319725
dependencies:
1969419726
has-flag "^4.0.0"
1969519727

19696-
supports-color@^8.0.0:
19728+
supports-color@^8.0.0, supports-color@^8.1.0:
1969719729
version "8.1.1"
1969819730
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c"
1969919731
integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==
@@ -20139,6 +20171,11 @@ tr46@~0.0.3:
2013920171
resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.3.9.tgz#717b8f220cc0bb7b44e40514c22b2e8bbc70d8b9"
2014020172
integrity sha1-cXuPIgzAu3tE5AUUwisui7xw2Lk=
2014120173

20174+
tree-kill@^1.2.2:
20175+
version "1.2.2"
20176+
resolved "https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.2.tgz#4ca09a9092c88b73a7cdc5e8a01b507b0790a0cc"
20177+
integrity sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==
20178+
2014220179
trim-newlines@^1.0.0:
2014320180
version "1.0.0"
2014420181
resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613"
@@ -21947,7 +21984,7 @@ yargs@^16.2.0:
2194721984
y18n "^5.0.5"
2194821985
yargs-parser "^20.2.2"
2194921986

21950-
yargs@^17.1.1:
21987+
yargs@^17.1.1, yargs@^17.3.1:
2195121988
version "17.5.1"
2195221989
resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.5.1.tgz#e109900cab6fcb7fd44b1d8249166feb0b36e58e"
2195321990
integrity sha512-t6YAJcxDkNX7NFYiVtKvWUz8l+PaKTLiL63mJYWR2GnHq2gjEWISzsLp9wg3aY36dY1j+gfIEL3pIF+XlJJfbA==

0 commit comments

Comments
 (0)