Skip to content
Closed
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changeset/early-countries-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'polaris.shopify.com': patch
---

Copy polaris-react css to keep local dev in sync
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ node_modules
/polaris.shopify.com/public/sitemap.xml
/polaris.shopify.com/public/og-images
/polaris.shopify.com/public/playroom
/polaris.shopify.com/public/polaris-styles.css
5 changes: 3 additions & 2 deletions polaris.shopify.com/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"build": "yarn gen-assets && playroom build && next build",
"start": "next start",
"dev": "run-p dev:*",
"dev": "yarn get-styles && run-p dev:*",
"dev:server": "open http://localhost:3000 && next dev",
"dev:playroom": "playroom start",
"dev:watch-md": "node scripts/watch-md.mjs",
Expand All @@ -16,7 +16,8 @@
"create-component": "generact --root src/components src/components/Template/Template.tsx",
"gen-sitemap": "yarn next-sitemap",
"get-props": "tsc ./scripts/get-props/src/get-props.ts --target esnext --module node16 --types \"react\" --outDir ./scripts/tmp && node ./scripts/tmp/scripts/get-props/src/get-props.js && rm -rf ./scripts/tmp",
"gen-assets": "node scripts/gen-assets.mjs"
"gen-assets": "node scripts/gen-assets.mjs",
"get-styles": "node scripts/get-styles.mjs"
},
"dependencies": {
"@floating-ui/react-dom-interactions": "^0.10.1",
Expand Down
12 changes: 12 additions & 0 deletions polaris.shopify.com/scripts/get-styles.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import fs from 'fs';

const builtStylesPath = '../polaris-react/build/esm/styles.css';
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm assuming Polaris is always built when yarn dev runs, otherwise other things would fail as well, right?

Copy link
Member

Choose a reason for hiding this comment

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

Only if it happens at the root of the monorepo. This could be a little bit confusing if someone is running just the website.

const fileDestination = 'public/polaris-styles.css';

fs.copyFile(builtStylesPath, fileDestination, (error) => {
if (error) {
throw new Error(`Error copying styles file: ${error}`);
}

console.log('✅ Copied polaris styles');
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import {ComponentType} from 'react';
import styles from './PolarisExampleWrapper.module.scss';

const stylesheetHref =
'https://unpkg.com/@shopify/polaris@latest/build/esm/styles.css';
process.env.NODE_ENV === 'development'
? '/polaris-styles.css'
: 'https://unpkg.com/@shopify/polaris@latest/build/esm/styles.css';

export const withPolarisExample = (Component: ComponentType) => {
const PolarisHOC = (props: any) => {
Expand Down