@chrisauret/styled-jsx-plugin-sass 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +94 -0
- package/index.js +53 -0
- package/package.json +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Thream
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
<h1 align="center">Thream/styled-jsx-plugin-sass</h1>
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<strong>Plugin to add <a href="https://sass-lang.com/">Sass</a> support to <a href="https://github.com/vercel/styled-jsx">styled-jsx</a>.</strong>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>⚠️ This project is not maintained anymore, you can still use the code as you wish and fork it to maintain it yourself.</strong>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="./CONTRIBUTING.md"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat" /></a>
|
|
13
|
+
<a href="./LICENSE"><img src="https://img.shields.io/badge/licence-MIT-blue.svg" alt="Licence MIT"/></a>
|
|
14
|
+
<a href="./CODE_OF_CONDUCT.md"><img src="https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg" alt="Contributor Covenant" /></a>
|
|
15
|
+
<br />
|
|
16
|
+
<a href="https://github.com/Thream/styled-jsx-plugin-sass/actions/workflows/lint.yml"><img src="https://github.com/Thream/styled-jsx-plugin-sass/actions/workflows/lint.yml/badge.svg?branch=develop" /></a>
|
|
17
|
+
<a href="https://github.com/Thream/styled-jsx-plugin-sass/actions/workflows/test.yml"><img src="https://github.com/Thream/styled-jsx-plugin-sass/actions/workflows/test.yml/badge.svg?branch=develop" /></a>
|
|
18
|
+
<br />
|
|
19
|
+
<a href="https://conventionalcommits.org"><img src="https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg" alt="Conventional Commits" /></a>
|
|
20
|
+
<a href="https://github.com/semantic-release/semantic-release"><img src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg" alt="semantic-release" /></a>
|
|
21
|
+
<a href="https://www.npmjs.com/package/@styled-jsx/plugin-sass"><img src="https://img.shields.io/npm/v/@styled-jsx/plugin-sass.svg" alt="npm version"></a>
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
## 📜 About
|
|
25
|
+
|
|
26
|
+
Use [Sass](https://sass-lang.com/) with [styled-jsx](https://github.com/vercel/styled-jsx) 💥
|
|
27
|
+
|
|
28
|
+
This repository was originally forked from [giuseppeg/styled-jsx-plugin-sass](https://github.com/giuseppeg/styled-jsx-plugin-sass) & it is not intended to take any credit but to improve the code from now on.
|
|
29
|
+
|
|
30
|
+
## 💾 Install
|
|
31
|
+
|
|
32
|
+
Install the package and [sass](https://www.npmjs.com/package/sass) version you need (it is a peer dependency).
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
npm install --save-dev sass @styled-jsx/plugin-sass
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## ⚙️ Usage
|
|
39
|
+
|
|
40
|
+
Add `@styled-jsx/plugin-sass` to the `styled-jsx`'s `plugins` in your babel configuration (e.g. `.babelrc.json`):
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"presets": [
|
|
45
|
+
[
|
|
46
|
+
"next/babel",
|
|
47
|
+
{
|
|
48
|
+
"styled-jsx": {
|
|
49
|
+
"plugins": ["@styled-jsx/plugin-sass"]
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Sass options
|
|
58
|
+
|
|
59
|
+
Sass can be configured using `sassOptions`. This is useful for setting options such as `data` or `includePaths`, see all the available options in [Sass README](https://github.com/sass/node-sass#Options).
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"presets": [
|
|
64
|
+
[
|
|
65
|
+
"next/babel",
|
|
66
|
+
{
|
|
67
|
+
"styled-jsx": {
|
|
68
|
+
"plugins": [
|
|
69
|
+
[
|
|
70
|
+
"@styled-jsx/plugin-sass",
|
|
71
|
+
{
|
|
72
|
+
"sassOptions": {
|
|
73
|
+
"includePaths": ["./styles"],
|
|
74
|
+
"data": "$test-color: #ff0000"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## 💡 Contributing
|
|
87
|
+
|
|
88
|
+
Anyone can help to improve the project, submit a Feature Request, a bug report or even correct a simple spelling mistake.
|
|
89
|
+
|
|
90
|
+
The steps to contribute can be found in the [CONTRIBUTING.md](./CONTRIBUTING.md) file.
|
|
91
|
+
|
|
92
|
+
## 📄 License
|
|
93
|
+
|
|
94
|
+
[MIT](./LICENSE)
|
package/index.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const sass = require('sass')
|
|
2
|
+
const stripIndent = require('strip-indent')
|
|
3
|
+
|
|
4
|
+
module.exports = (css, settings) => {
|
|
5
|
+
const cssWithPlaceholders = css
|
|
6
|
+
.replace(
|
|
7
|
+
/%%styled-jsx-placeholder-(\d+)%%%(\w*[ ),;!{])/g,
|
|
8
|
+
(_, id, p1) => `styled-jsx-percent-placeholder-${id}-${p1}`
|
|
9
|
+
)
|
|
10
|
+
.replace(
|
|
11
|
+
/%%styled-jsx-placeholder-(\d+)%%(\w*[ ),;!{])/g,
|
|
12
|
+
(_, id, p1) => `styled-jsx-placeholder-${id}-${p1}`
|
|
13
|
+
)
|
|
14
|
+
.replace(
|
|
15
|
+
/%%styled-jsx-placeholder-(\d+)%%%/g,
|
|
16
|
+
(_, id) => `/*%%styled-jsx-percent-placeholder-${id}%%*/`
|
|
17
|
+
)
|
|
18
|
+
.replace(
|
|
19
|
+
/%%styled-jsx-placeholder-(\d+)%%/g,
|
|
20
|
+
(_, id) => `/*%%styled-jsx-placeholder-${id}%%*/`
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
const optionData = (settings.sassOptions && settings.sassOptions.data) || ''
|
|
24
|
+
const data =
|
|
25
|
+
stripIndent(optionData) + '\n' + stripIndent(cssWithPlaceholders)
|
|
26
|
+
|
|
27
|
+
// Map legacy sassOptions to modern API options
|
|
28
|
+
const { data: _, ...sassOptions } = settings.sassOptions || {}
|
|
29
|
+
const preprocessed = sass
|
|
30
|
+
.compileString(data, {
|
|
31
|
+
...sassOptions,
|
|
32
|
+
syntax: sassOptions.indentedSyntax ? 'indented' : 'scss'
|
|
33
|
+
})
|
|
34
|
+
.css.toString()
|
|
35
|
+
|
|
36
|
+
return preprocessed
|
|
37
|
+
.replace(
|
|
38
|
+
/styled-jsx-percent-placeholder-(\d+)-(\w*[ ),;!{])/g,
|
|
39
|
+
(_, id, p1) => `%%styled-jsx-placeholder-${id}%%%${p1}`
|
|
40
|
+
)
|
|
41
|
+
.replace(
|
|
42
|
+
/styled-jsx-placeholder-(\d+)-(\w*[ ),;!{])/g,
|
|
43
|
+
(_, id, p1) => `%%styled-jsx-placeholder-${id}%%${p1}`
|
|
44
|
+
)
|
|
45
|
+
.replace(
|
|
46
|
+
/\/\*%%styled-jsx-percent-placeholder-(\d+)%%\*\//g,
|
|
47
|
+
(_, id) => `%%styled-jsx-placeholder-${id}%%%`
|
|
48
|
+
)
|
|
49
|
+
.replace(
|
|
50
|
+
/\/\*%%styled-jsx-placeholder-(\d+)%%\*\//g,
|
|
51
|
+
(_, id) => `%%styled-jsx-placeholder-${id}%%`
|
|
52
|
+
)
|
|
53
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@chrisauret/styled-jsx-plugin-sass",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Plugin to add Sass support to styled-jsx (fork of @styled-jsx/plugin-sass).",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=12.0.0"
|
|
9
|
+
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public",
|
|
12
|
+
"provenance": true
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"styled-jsx-plugin",
|
|
16
|
+
"styled-jsx",
|
|
17
|
+
"sass",
|
|
18
|
+
"scss",
|
|
19
|
+
"css-in-js"
|
|
20
|
+
],
|
|
21
|
+
"author": "Chris Auret",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/chrisauret/styled-jsx-plugin-sass.git"
|
|
25
|
+
},
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/chrisauret/styled-jsx-plugin-sass/issues"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://github.com/chrisauret/styled-jsx-plugin-sass#readme",
|
|
30
|
+
"standard": {
|
|
31
|
+
"envs": [
|
|
32
|
+
"node",
|
|
33
|
+
"mocha"
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"index.js"
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"lint:commit": "commitlint",
|
|
41
|
+
"lint:editorconfig": "editorconfig-checker",
|
|
42
|
+
"lint:markdown": "markdownlint-cli2",
|
|
43
|
+
"lint:javascript": "standard",
|
|
44
|
+
"release": "semantic-release",
|
|
45
|
+
"test": "mocha test.js",
|
|
46
|
+
"_postinstall": "husky install",
|
|
47
|
+
"prepublishOnly": "pinst --disable",
|
|
48
|
+
"postpublish": "pinst --enable"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"strip-indent": "3.0.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@commitlint/cli": "17.6.6",
|
|
55
|
+
"@commitlint/config-conventional": "17.6.6",
|
|
56
|
+
"@types/node": "20.3.3",
|
|
57
|
+
"editorconfig-checker": "5.1.1",
|
|
58
|
+
"husky": "8.0.3",
|
|
59
|
+
"markdownlint-cli2": "0.8.1",
|
|
60
|
+
"markdownlint-rule-relative-links": "2.1.0",
|
|
61
|
+
"mocha": "10.2.0",
|
|
62
|
+
"pinst": "3.0.0",
|
|
63
|
+
"sass": "1.97.3",
|
|
64
|
+
"semantic-release": "21.0.6",
|
|
65
|
+
"standard": "17.1.0"
|
|
66
|
+
},
|
|
67
|
+
"peerDependencies": {
|
|
68
|
+
"sass": "*"
|
|
69
|
+
}
|
|
70
|
+
}
|