Skip to content

Commit

Permalink
refactor: scope preflight css to className
Browse files Browse the repository at this point in the history
  • Loading branch information
awesthouse committed May 9, 2024
1 parent af27b61 commit 779f744
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 7 deletions.
2 changes: 1 addition & 1 deletion example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/>
<title>dm-core-packages</title>
</head>
<body>
<body className="dm-preflight">
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script src="src/index.tsx" type="module"></script>
Expand Down
7 changes: 4 additions & 3 deletions packages/dm-core-plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
"lodash": "^4.17.21",
"luxon": "^3.4.3",
"mermaid": "^10.0.0",
"react-grid-system": "^8.1.9",
"react-hook-form": "^7.48.2",
"react-toastify": "^9.1.3",
"ts-node": "^10.9.1",
"yaml": "^2.3.2",
"react-grid-system": "^8.1.9"
"yaml": "^2.3.2"
},
"devDependencies": {
"@biomejs/biome": "1.4.1",
Expand All @@ -41,6 +41,7 @@
"react-router-dom": ">=5.1.2",
"shx": " 0.3.4",
"tailwindcss": "^3.4.0",
"tailwindcss-scoped-preflight": "^3.2.1",
"ts-jest": "^29.1.0",
"ts-loader": "^9.3.1",
"typescript": "^5.1.6"
Expand All @@ -58,7 +59,7 @@
"types": "dist/index.d.ts",
"scripts": {
"prebuild": "shx rm -rf dist",
"build:css": "npx tailwindcss -i ./src/styles/main.css -o ./dist/main.css --minify",
"build:css": "tailwindcss -i ./src/styles/main.css -o ./dist/main.css --minify",
"build": "tsc && yarn build:css",
"test": "jest test",
"test-watch": "jest test --watchAll"
Expand Down
3 changes: 3 additions & 0 deletions packages/dm-core-plugins/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,6 @@ export default ({
),
},
} as TUiPluginMap)

// NEEDS TO BE HERE TO FORCE TAILWIND BUILD TO RECOGNIZE OUR PREFLIGHT PREFIX
// .dm-preflight
11 changes: 10 additions & 1 deletion packages/dm-core-plugins/tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import {
isolateInsideOfContainer,
scopedPreflightStyles,
} from 'tailwindcss-scoped-preflight'

/** @type {import('tailwindcss').Config} */
module.exports = {
content: ['./src/**/*.{ts,js,tsx,jsx}'],
Expand All @@ -15,5 +20,9 @@ module.exports = {
},
},
},
plugins: [],
plugins: [
scopedPreflightStyles({
isolationStrategy: isolateInsideOfContainer('.dm-preflight'),
}),
],
}
3 changes: 2 additions & 1 deletion packages/dm-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"postcss": "^8.4.31",
"shx": " 0.3.4",
"tailwindcss": "^3.4.0",
"tailwindcss-scoped-preflight": "^3.2.1",
"ts-jest": "^29.1.1",
"ts-loader": "^9.3.1",
"typescript": "^5.1.6"
Expand All @@ -56,7 +57,7 @@
"types": "dist/index.d.ts",
"scripts": {
"prebuild": "shx rm -rf dist",
"build:css": "npx tailwindcss -i ./src/styles/base.css -o ./dist/main.css --minify",
"build:css": "tailwindcss -i ./src/styles/base.css -o ./dist/main.css --minify",
"build": "tsc && yarn build:css",
"test": "jest test"
}
Expand Down
3 changes: 3 additions & 0 deletions packages/dm-core/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ export * from './utils/objectUtilities'
export * from './utils/truncatePathString'
export * from './utils/variables'
export * from './utils/stringUtilities'

// NEEDS TO BE HERE TO FORCE TAILWIND BUILD TO RECOGNIZE OUR PREFLIGHT PREFIX
// .dm-preflight
11 changes: 10 additions & 1 deletion packages/dm-core/tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import {
isolateInsideOfContainer,
scopedPreflightStyles,
} from 'tailwindcss-scoped-preflight'

/** @type {import('tailwindcss').Config} */
module.exports = {
content: ['./src/**/*.{ts,js,tsx,jsx}'],
Expand All @@ -15,5 +20,9 @@ module.exports = {
},
},
},
plugins: [],
plugins: [
scopedPreflightStyles({
isolationStrategy: isolateInsideOfContainer('.dm-preflight'),
}),
],
}

0 comments on commit 779f744

Please sign in to comment.