@adamlui/scss-to-css 1.5.1 → 1.6.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/README.md +144 -44
- package/docs/LICENSE.md +21 -9
- package/docs/SECURITY.md +17 -5
- package/docs/zh-cn/LICENSE.md +21 -0
- package/docs/zh-cn/README.md +228 -0
- package/docs/zh-cn/SECURITY.md +17 -0
- package/docs/zh-tw/LICENSE.md +21 -0
- package/docs/zh-tw/README.md +227 -0
- package/docs/zh-tw/SECURITY.md +17 -0
- package/package.json +48 -48
- package/scss-to-css.js +208 -159
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
<div align="right">
|
|
2
|
+
<h6>
|
|
3
|
+
<picture>
|
|
4
|
+
<source type="image/svg+xml" media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/earth-icon/white/icon32.svg">
|
|
5
|
+
<img height=14 src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/earth-icon/black/icon32.svg">
|
|
6
|
+
</picture>
|
|
7
|
+
繁體中文 |
|
|
8
|
+
<a href="../..#readme">English</a> |
|
|
9
|
+
<a href="../zh-cn#readme">简体中文</a>
|
|
10
|
+
</h6>
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
# { } scss-to-css.js
|
|
14
|
+
|
|
15
|
+
### 將所有 SCSS 檔案遞歸編譯為縮小的 CSS。
|
|
16
|
+
|
|
17
|
+
<a href="https://www.npmjs.com/package/@adamlui/scss-to-css"><img height=31 src="https://img.shields.io/npm/dt/%40adamlui%2Fscss-to-css?label=%E4%B8%8B%E8%BC%89&logo=npm&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
18
|
+
<a href="#%EF%B8%8F-mit-%E8%AE%B8%E5%8F%AF%E8%AF%81"><img height=31 src="https://img.shields.io/badge/許可證-MIT-red.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
19
|
+
<a href="https://www.npmjs.com/package/@adamlui/scss-to-css?activeTab=versions"><img height=31 src="https://img.shields.io/badge/最新版本-1.6.0-fc7811.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
20
|
+
<a href="https://www.npmjs.com/package/@adamlui/scss-to-css?activeTab=code"><img height=31 src="https://img.shields.io/npm/unpacked-size/%40adamlui%2Fscss-to-css?label=%E6%8B%86%E5%B0%81%E5%B0%BA%E5%AF%B8&style=for-the-badge&logo=ebox&logoColor=white&color=blue&labelColor=464646"></a>
|
|
21
|
+
<a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_js-utils:scss-to-css/scss-to-css.js"><img height=31 src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsonarcloud.io%2Fapi%2Fmeasures%2Fcomponent%3Fcomponent%3Dadamlui_js-utils%3Ascss-to-css%2Fscss-to-css.js%26metricKeys%3Dvulnerabilities&query=%24.component.measures.0.value&style=for-the-badge&logo=sonarcloud&logoColor=white&labelColor=464646&label=%E6%BC%8F%E6%B4%9E&color=gold"></a>
|
|
22
|
+
|
|
23
|
+
<img height=8px width="100%" src="https://github.com/adamlui/js-utils/blob/main/docs/images/aqua-separator.png">
|
|
24
|
+
|
|
25
|
+
## ⚡ 如何安裝
|
|
26
|
+
|
|
27
|
+
作為**全域實用程式**:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
npm install -g @adamlui/scss-to-css
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
作為**開發人員依賴**(例如,對於建置腳本):
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
npm install -D @adamlui/scss-to-css
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
作為**運行時依賴**(例如,用於動態編譯):
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
npm install @adamlui/scss-to-css
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## 💻 命令列使用
|
|
46
|
+
|
|
47
|
+
基本的**全域命令**是:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
scss-to-css
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
範例輸出:
|
|
54
|
+
|
|
55
|
+
<img src="https://github.com/adamlui/js-utils/blob/main/scss-to-css/media/images/sample-output.png">
|
|
56
|
+
|
|
57
|
+
**💡 筆記:** 預設也會產生來源映射,除非傳遞 `-S` 或 `--no-source-maps`。
|
|
58
|
+
|
|
59
|
+
#
|
|
60
|
+
|
|
61
|
+
指定**輸入/輸出**路徑:
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
scss-to-css [input_path] [output_path]
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
- `[input_path]`: SCSS 檔案或包含要編譯的 SCSS 檔案的目錄的路徑,相對於目前工作目錄。
|
|
68
|
+
- `[output_path]`: 將儲存 CSS + 來源對應檔案的檔案或目錄的路徑,相對於原始檔案位置(如果未提供,則使用 `css/`)。
|
|
69
|
+
|
|
70
|
+
**💡 注意:** 如果傳遞資料夾,檔案將被遞歸處理,除非傳遞 `-R` 或 `--no-recursion`。
|
|
71
|
+
|
|
72
|
+
#
|
|
73
|
+
|
|
74
|
+
若要用作 **套件腳本**,請在專案的 `package.json` 中:
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
"scripts": {
|
|
78
|
+
"build:css": "<scss-to-css-cmd>"
|
|
79
|
+
},
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
將 `<scss-to-css-cmd>` 替換為 `scss-to-css` + 可選參數。 然後,可以使用 `npm run build:css` 來執行該指令。
|
|
83
|
+
<br><br>
|
|
84
|
+
|
|
85
|
+
### 命令範例
|
|
86
|
+
|
|
87
|
+
編譯 **目前目錄** 中的所有 SCSS 檔案(輸出到 `css/`):
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
scss-to-css
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
編譯 **特定目錄** 中的所有 SCSS 檔案(輸出到 `path/to/your/directory/css/`):
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
scss-to-css path/to/your/directory
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
編譯一個**特定檔案**(輸出到 `path/to/your/css/file.min.css`):
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
scss-to-css path/to/your/file.scss
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
指定 **輸入和輸出** 目錄(輸出到 `output_folder/`):
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
scss-to-css input_folder output_folder
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**💡 注意:** 除非傳遞 `-M` 或 `--no-minify` ,否則輸出 CSS 會被縮小。
|
|
112
|
+
<br><br>
|
|
113
|
+
|
|
114
|
+
### 命令列選項
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
配置選項:
|
|
118
|
+
-n, --dry-run 實際上並不會縮小文件,只是顯示它們是否會被處理。
|
|
119
|
+
-d, --include-dotfolders 在檔案搜尋中包含點資料夾。
|
|
120
|
+
-S, --no-source-maps 防止產生來源映射。
|
|
121
|
+
-M, --no-minify 禁用輸出 CSS 的縮小。
|
|
122
|
+
-R, --no-recursion 停用遞歸檔案搜尋。
|
|
123
|
+
-q, --quiet 禁止錯誤以外的所有日誌記錄。
|
|
124
|
+
|
|
125
|
+
訊息命令:
|
|
126
|
+
-h, --help 顯示幫助畫面。
|
|
127
|
+
-v, --version 顯示版本號。
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## 🔌 API 參考
|
|
131
|
+
|
|
132
|
+
您也可以將 **scss-to-css** 匯入您的應用程式以使用其 API 方法,無論是作為 ECMAScript 模組還是 CommonJS 模組。
|
|
133
|
+
|
|
134
|
+
#### ESM:
|
|
135
|
+
|
|
136
|
+
```js
|
|
137
|
+
import * as scssToCSS from '@adamlui/scss-to-css';
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
#### CJS:
|
|
141
|
+
|
|
142
|
+
```js
|
|
143
|
+
const scssToCSS = require('@adamlui/scss-to-css');
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### compile(inputPath, options)
|
|
147
|
+
|
|
148
|
+
此函數將在 `inputPath` 中找到的 SCSS 編譯為 CSS 資料。
|
|
149
|
+
|
|
150
|
+
如果傳遞 **檔案路徑**,則檔案的程式碼將編譯為 CSS,然後傳回一個包含 `srcPath` + `code` + `error` 的物件:
|
|
151
|
+
|
|
152
|
+
```js
|
|
153
|
+
const compileResult = scssToCSS.compile('assets/style.scss');
|
|
154
|
+
console.log(compileResult.error); // 執行階段錯誤,如果沒有錯誤則為 `undefined`
|
|
155
|
+
console.log(compileResult.code); // 編譯後的 assets/style.scss CSS 輸出
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
如果传递 **目录路径**,则搜索 SCSS 文件(默认情况下递归),加载每个文件的代码并编译,然后返回包含 `srcPath` + `code` + `error` 的对象数组:
|
|
159
|
+
|
|
160
|
+
```js
|
|
161
|
+
const results = scssToCSS.compile('.');
|
|
162
|
+
results.forEach(result =>
|
|
163
|
+
console.log(result.srcPath) // 工作目錄 + 所有巢狀目錄中 SCSS 檔案的路徑
|
|
164
|
+
);
|
|
165
|
+
console.log(results[1].code); // 如果找到,則編譯第二個 SCSS 檔案的 CSS 輸出,如果找不到,則為 `undefined`
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
選項是布林值,作為物件屬性傳遞。 例如:
|
|
169
|
+
|
|
170
|
+
```js
|
|
171
|
+
scssToCSS.compile(inputDir, { minify: false });
|
|
172
|
+
// 傳回 `.code` 包含未縮小 CSS 的資料對象
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
可能的參數(及其預設設定)有:
|
|
176
|
+
|
|
177
|
+
```
|
|
178
|
+
recursive (true) 如果傳遞目錄路徑,則遞歸搜尋巢狀檔案。
|
|
179
|
+
verbose (true) 在控制台/終端機中顯示日誌記錄。
|
|
180
|
+
dotFolders (false) 在檔案搜尋中包含點資料夾。
|
|
181
|
+
minify (true) 縮小輸出 CSS。
|
|
182
|
+
sourceMaps (true) 產生 CSS 來源映射。
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### findSCSS(searchDir, options)
|
|
186
|
+
|
|
187
|
+
此函數搜尋傳遞的 `searchDir` 字串中的所有 SCSS 檔案(對於發現 [`compile()`](#compileinputpath-options) 將處理哪些檔案很有用)並傳回包含其檔案路徑的陣列。
|
|
188
|
+
|
|
189
|
+
選項是布林值,作為物件屬性傳遞。 例如:
|
|
190
|
+
|
|
191
|
+
```js
|
|
192
|
+
scssToCSS.findSCSS(searchDir, { recursive: false });
|
|
193
|
+
// 傳回包含恰好位於 `searchDir` 中的 SCSS 檔案的檔案路徑的陣列
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
可能的參數(及其預設設定)有:
|
|
197
|
+
|
|
198
|
+
```
|
|
199
|
+
recursive (true) 如果傳遞目錄路徑,則遞歸搜尋巢狀檔案。
|
|
200
|
+
verbose (false) 在控制台/終端機中顯示日誌記錄。
|
|
201
|
+
dotFolders (false) 在檔案搜尋中包含點資料夾。
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
<br>
|
|
205
|
+
|
|
206
|
+
## 💖 支援
|
|
207
|
+
|
|
208
|
+
如果這對您有幫助,請考慮[給予 GitHub ⭐](https://github.com/adamlui/js-utils)!
|
|
209
|
+
<br><br>
|
|
210
|
+
|
|
211
|
+
## 🏛️ MIT 许可证
|
|
212
|
+
|
|
213
|
+
**版權所有 © 2023–2024 [刘展鹏 (Adam Lui)](https://github.com/adamlui)**
|
|
214
|
+
|
|
215
|
+
特此免費授予任何取得副本的人許可本軟體和相關文件文件(『軟體』),處理在軟體中不受限制,包括但不限於權利使用、複製、修改、合併、發布、分發、再授權和/或出售該軟體的副本,並允許該軟體是提供這樣做,但須滿足以下條件:
|
|
216
|
+
|
|
217
|
+
上述版權聲明和本許可聲明應包含在所有軟體的副本或重要部分。
|
|
218
|
+
|
|
219
|
+
本軟體『依現況』提供,不提供任何形式的明示或保證暗示的,包括但不限於適銷性保證,適用於特定目的和非侵權。 在任何情況下都不得作者或版權持有人對任何索賠、損害或其他責任,無論是在合約、侵權或其他方面的行為中,由以下原因引起,出於或與軟體或使用或其他交易有關軟體。
|
|
220
|
+
|
|
221
|
+
<br>
|
|
222
|
+
|
|
223
|
+
<img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
|
|
224
|
+
|
|
225
|
+
<a href="https://github.com/adamlui/js-utils">**家**</a> /
|
|
226
|
+
<a href="https://github.com/adamlui/js-utils/discussions">讨论</a> /
|
|
227
|
+
<a href="#--scss-to-css">回到顶部 ↑</a>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<div align="right">
|
|
2
|
+
<h6>
|
|
3
|
+
<picture>
|
|
4
|
+
<source type="image/svg+xml" media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/earth-icon/white/icon32.svg">
|
|
5
|
+
<img height=14 src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/earth-icon/black/icon32.svg">
|
|
6
|
+
</picture>
|
|
7
|
+
繁體中文 |
|
|
8
|
+
<a href="../SECURITY.md">English</a> |
|
|
9
|
+
<a href="../zh-cn/SECURITY.md">简体中文</a>
|
|
10
|
+
</h6>
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
# 🛡️ 安全策略
|
|
14
|
+
|
|
15
|
+
如果您發現漏洞,請打開[安全公告草案](https://github.com/adamlui/js-utils/security/advisories/new)。
|
|
16
|
+
|
|
17
|
+
也歡迎拉取請求,但出於安全原因,請發送電子郵件至 <adam@kudoai.com> 並等待回復後再公開。
|
package/package.json
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@adamlui/scss-to-css",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Recursively compile all SCSS files into minified CSS",
|
|
5
|
-
"author": {
|
|
6
|
-
"name": "Adam Lui",
|
|
7
|
-
"email": "adam@kudoai.com",
|
|
8
|
-
"url": "https://github.com/adamlui"
|
|
9
|
-
},
|
|
10
|
-
"homepage": "https://github.com/adamlui/js-utils",
|
|
11
|
-
"license": "MIT",
|
|
12
|
-
"main": "scss-to-css.js",
|
|
13
|
-
"bin": {
|
|
14
|
-
"scsstocss": "scss-to-css.js",
|
|
15
|
-
"scss-to-css": "scss-to-css.js"
|
|
16
|
-
},
|
|
17
|
-
"scripts": {
|
|
18
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
19
|
-
"bump:patch": "bash utils/bump.sh patch",
|
|
20
|
-
"bump:minor": "bash utils/bump.sh minor",
|
|
21
|
-
"bump:major": "bash utils/bump.sh major",
|
|
22
|
-
"publish:patch": "bash utils/bump.sh patch --publish",
|
|
23
|
-
"publish:minor": "bash utils/bump.sh minor --publish",
|
|
24
|
-
"publish:major": "bash utils/bump.sh major --publish"
|
|
25
|
-
},
|
|
26
|
-
"repository": {
|
|
27
|
-
"type": "git",
|
|
28
|
-
"url": "git+https://github.com/adamlui/js-utils.git"
|
|
29
|
-
},
|
|
30
|
-
"keywords": [
|
|
31
|
-
"scss",
|
|
32
|
-
"sass",
|
|
33
|
-
"css",
|
|
34
|
-
"stylesheets",
|
|
35
|
-
"compiler",
|
|
36
|
-
"minifier"
|
|
37
|
-
],
|
|
38
|
-
"bugs": {
|
|
39
|
-
"url": "https://github.com/adamlui/js-utils/issues"
|
|
40
|
-
},
|
|
41
|
-
"dependencies": {
|
|
42
|
-
"sass": "^1.71.1"
|
|
43
|
-
},
|
|
44
|
-
"funding": {
|
|
45
|
-
"type": "github",
|
|
46
|
-
"url": "https://github.com/sponsors/adamlui"
|
|
47
|
-
}
|
|
48
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@adamlui/scss-to-css",
|
|
3
|
+
"version": "1.6.0",
|
|
4
|
+
"description": "Recursively compile all SCSS files into minified CSS",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Adam Lui",
|
|
7
|
+
"email": "adam@kudoai.com",
|
|
8
|
+
"url": "https://github.com/adamlui"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/adamlui/js-utils",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"main": "scss-to-css.js",
|
|
13
|
+
"bin": {
|
|
14
|
+
"scsstocss": "scss-to-css.js",
|
|
15
|
+
"scss-to-css": "scss-to-css.js"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
19
|
+
"bump:patch": "bash utils/bump.sh patch",
|
|
20
|
+
"bump:minor": "bash utils/bump.sh minor",
|
|
21
|
+
"bump:major": "bash utils/bump.sh major",
|
|
22
|
+
"publish:patch": "bash utils/bump.sh patch --publish",
|
|
23
|
+
"publish:minor": "bash utils/bump.sh minor --publish",
|
|
24
|
+
"publish:major": "bash utils/bump.sh major --publish"
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/adamlui/js-utils.git"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"scss",
|
|
32
|
+
"sass",
|
|
33
|
+
"css",
|
|
34
|
+
"stylesheets",
|
|
35
|
+
"compiler",
|
|
36
|
+
"minifier"
|
|
37
|
+
],
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/adamlui/js-utils/issues"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"sass": "^1.71.1"
|
|
43
|
+
},
|
|
44
|
+
"funding": {
|
|
45
|
+
"type": "github",
|
|
46
|
+
"url": "https://github.com/sponsors/adamlui"
|
|
47
|
+
}
|
|
48
|
+
}
|