Skip to content

Commit

Permalink
feat: add support of package imports for Sass (#4)
Browse files Browse the repository at this point in the history
* test: add support of `node_modules` mocks

* chore: run prettier in Idea

* feat(sass): resolve `~<pkg>` to the `sass` field in the `package.json`

* test: add tests for resolving `~<pkg>` urls in Sass files

* chore: add changeset

* docs: add section about Sass imports

* build: update dependencies

* chore: add new changeset and update an existing one

* chore: enable ESlint in Idea

* style: fix ESLint problems
  • Loading branch information
demiazz authored Jul 11, 2023
1 parent d69a787 commit 8dddd8d
Show file tree
Hide file tree
Showing 19 changed files with 472 additions and 186 deletions.
5 changes: 5 additions & 0 deletions .changeset/blue-terms-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tabula/forge': patch
---

update dependencies
31 changes: 31 additions & 0 deletions .changeset/silent-lobsters-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
'@tabula/forge': minor
---

adds support of packages resolve in the Sass

The `forge` resolves external packages through `~<pkg>` urls.

Example:

```scss
@use `~@tabula/ui-theme` as theme;

.root {
background-color: theme.$color--primary;
}
```

It will search `<pkg>` in dependencies through Node.js `require`, and try to read `sass` field in the `package.json`
of the founded package.

Example:

```json
{
"name": "@tabula/ui-theme",
"sass": "./sass/index.scss"
}
```

will be resolved to the `<node_modules>/@tabula/ui-theme/sass/index.scss`.
6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/prettier.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,26 @@ The `forge` supports usage of the [PostCSS](https://postcss.org/) and

You should use `*.pcss` extension for PostCSS and `*.scss` for the Sass.

#### Sass Imports

We support imports in format of `~<pkg>`. It's similar to the Webpack, but
has own restrictions.

The `forge` doesn't support paths inside of the package. It does searce
the `package.json` of the given package, and try to read `sass` field inside
of it.

Example:

```json
{
"name": "@tabula/ui-theme",
"sass": "./sass/index.scss"
}
```

will be resolved to the `<node_modules>/@tabula/ui-theme/sass/index.scss`.

### vanilla-extract

We support the [vanilla-extract](https://vanilla-extract.style/).
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@
"@tabula/prettier-config": "^0.0.0",
"@tabula/typescript-config": "^0.0.0",
"@types/convert-source-map": "^2.0.0",
"@types/node": "^20.3.3",
"@types/node": "^20.4.1",
"@types/react": "^18.2.14",
"ava": "^5.3.1",
"eslint": "^8.44.0",
"lefthook": "^1.4.3",
"lefthook": "^1.4.4",
"prettier": "^2.8.8",
"tsx": "^3.12.7",
"typescript": "^5.1.6"
},
"dependencies": {
"@babel/core": "^7.22.5",
"@babel/core": "^7.22.8",
"@svgr/core": "^8.0.0",
"@svgr/plugin-jsx": "^8.0.1",
"@vanilla-extract/esbuild-plugin": "^2.2.2",
Expand All @@ -73,12 +73,12 @@
"convert-source-map": "^2.0.0",
"esbuild": "^0.18.11",
"find-up": "^6.3.0",
"postcss": "^8.4.24",
"postcss": "^8.4.25",
"postcss-load-config": "^4.0.1",
"postcss-modules": "^6.0.0",
"react-docgen": "^6.0.1",
"react-docgen-typescript": "^2.2.2",
"read-pkg-up": "^9.1.0",
"read-pkg-up": "^10.0.0",
"sass": "^1.63.6",
"source-map": "^0.7.4",
"svgo": "^3.0.2",
Expand Down
Loading

0 comments on commit 8dddd8d

Please sign in to comment.