-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
397 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
'@crackle/core': minor | ||
--- | ||
|
||
Crackle now supports importing external CSS. | ||
|
||
This is useful when consuming packages which come with their own CSS, such as [Pure React Carousel](https://github.com/express-labs/pure-react-carousel). | ||
|
||
External CSS can be imported with a side-effect `import`, same as how you would import a JavaScript or TypeScript module: | ||
|
||
```tsx | ||
// src/components/MyComponent.tsx | ||
import 'package-with-styles/dist/styles.css'; | ||
|
||
import { Component } from 'package-with-styles'; | ||
|
||
export const MyComponent = (props) => { | ||
<Component {...props} />; | ||
}; | ||
``` | ||
|
||
The side-effect import will be preserved in the output bundles. | ||
|
||
External CSS can also be imported with a CSS `@import` rule: | ||
|
||
```css | ||
/* src/components/MyComponent/third-party.css */ | ||
@import 'package-with-styles/dist/styles.css'; | ||
``` | ||
|
||
```tsx | ||
// src/components/MyComponent.tsx | ||
import './third-party.css'; | ||
|
||
export const MyComponent = () => { | ||
// ... | ||
}; | ||
``` | ||
|
||
When importing with a CSS `@import` rule, Crackle will bundle all external CSS into one file and output it to the `dist` directory. | ||
Package exports will also be updated so consumers can import the bundled CSS. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# managed by crackle | ||
/dist | ||
# end managed by crackle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "@sku-fixtures/package-with-styles" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.external { | ||
display: none; | ||
font-size: 9px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "@crackle-fixtures/with-styles", | ||
"version": "1.0.0", | ||
"private": true, | ||
"license": "MIT", | ||
"author": "SEEK", | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.mjs", | ||
"require": "./dist/index.cjs" | ||
}, | ||
"./dist/style.css": "./dist/style.css", | ||
"./package.json": "./package.json" | ||
}, | ||
"main": "./dist/index.cjs", | ||
"module": "./dist/index.mjs", | ||
"types": "./dist/index.d.ts", | ||
"files": [ | ||
"dist", | ||
"init" | ||
], | ||
"scripts": { | ||
"dev": "crackle dev", | ||
"fix": "crackle fix", | ||
"package": "crackle package" | ||
}, | ||
"dependencies": { | ||
"@crackle-fixtures/package-with-styles": "link:./package-with-styles", | ||
"@vanilla-extract/css": "^1.12.0", | ||
"react": "^18.2.0" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^18.0.21" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { style } from '@vanilla-extract/css'; | ||
|
||
export const redBorder = style({ | ||
border: '5px solid red', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import '@crackle-fixtures/package-with-styles/styles.css'; | ||
|
||
import './thirdparty.css'; | ||
|
||
import * as styles from './Component.css'; | ||
|
||
export default () => ( | ||
<div className={styles.redBorder}> | ||
<span className="external" /> | ||
</div> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as Component } from './Component'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@import '@crackle-fixtures/package-with-styles/styles.css'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.