@adamlui/scss-to-css 1.6.0 → 1.6.1

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 CHANGED
@@ -6,17 +6,21 @@
6
6
  </picture>
7
7
  &nbsp;English |
8
8
  <a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/zh-cn#readme">简体中文</a> |
9
- <a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/zh-tw#readme">繁體中文</a>
9
+ <a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/zh-tw#readme">繁體中文</a> |
10
+ <a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/hi#readme">हिंदी</a> |
11
+ <a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/bn#readme">বাংলা</a> |
12
+ <a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/mr#readme">मराठी</a> |
13
+ <a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/pa#readme">ਪੰਜਾਬੀ</a>
10
14
  </h6>
11
15
  </div>
12
16
 
13
- # { } scss-to-css.js
17
+ # { } scss-to-css
14
18
 
15
19
  ### Recursively compile all SCSS files into minified CSS.
16
20
 
17
21
  <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?logo=npm&logoColor=white&labelColor=464646&style=for-the-badge"></a>
18
22
  <a href="#%EF%B8%8F-mit-license"><img height=31 src="https://img.shields.io/badge/License-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/Latest_Build-1.6.0-fc7811.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
23
+ <a href="https://www.npmjs.com/package/@adamlui/scss-to-css?activeTab=versions"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.6.1-fc7811.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
20
24
  <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?style=for-the-badge&logo=ebox&logoColor=white&color=blue&labelColor=464646"></a>
21
25
  <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=Vulnerabilities&color=gold"></a>
22
26
 
@@ -30,20 +34,19 @@ As a **global utility**:
30
34
  npm install -g @adamlui/scss-to-css
31
35
  ```
32
36
 
33
- As a **dev dependency** (e.g. for build scripts):
37
+ As a **dev dependency** (e.g. for build scripts), from your project root:
34
38
 
35
39
  ```
36
40
  npm install -D @adamlui/scss-to-css
37
41
  ```
38
42
 
39
-
40
- As a **runtime dependency** (e.g. for on-the-fly compilation):
43
+ As a **runtime dependency** (e.g. for on-the-fly compilation), from your project root:
41
44
 
42
45
  ```
43
46
  npm install @adamlui/scss-to-css
44
47
  ```
45
48
 
46
- ## 💻 Usage
49
+ ## 💻 Command line usage
47
50
 
48
51
  The basic **global command** is:
49
52
 
@@ -162,9 +165,8 @@ If a **directory path** is passed, SCSS files are searched for (recursively by d
162
165
  ```js
163
166
  const results = scssToCSS.compile('.');
164
167
  results.forEach(result =>
165
- console.log(result.srcPath) // paths to SCSS files in working directory + all nested directories
166
- );
167
- console.log(results[1].code); // compiled CSS output of 2nd SCSS file if found, or `undefined` if not found
168
+ console.log(result.srcPath)); // paths to SCSS files in working directory + all nested directories
169
+ console.log(results[1].code); // compiled CSS output of 2nd SCSS file if found, or `undefined` if not found
168
170
  ```
169
171
 
170
172
  Options are boolean, passed as object properties. For example:
@@ -214,7 +216,7 @@ Please consider [giving a GitHub ⭐](https://github.com/adamlui/js-utils) if th
214
216
 
215
217
  ## 🏛️ MIT License
216
218
 
217
- **Copyright © 2024 [Adam Lui](https://github.com/adamlui)**
219
+ **Copyright © 2024 [Adam Lui](https://github.com/adamlui) & contributors**
218
220
 
219
221
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
220
222
 
@@ -228,4 +230,4 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
228
230
 
229
231
  <a href="https://github.com/adamlui/js-utils">**Home**</a> /
230
232
  <a href="https://github.com/adamlui/js-utils/discussions">Discuss</a> /
231
- <a href="#--scss-to-cssjs">Back to top ↑</a>
233
+ <a href="#--scss-to-css">Back to top ↑</a>
package/docs/LICENSE.md CHANGED
@@ -6,13 +6,17 @@
6
6
  </picture>
7
7
  &nbsp;English |
8
8
  <a href="zh-cn/LICENSE.md">简体中文</a> |
9
- <a href="zh-tw/LICENSE.md">繁體中文</a>
9
+ <a href="zh-tw/LICENSE.md">繁體中文</a> |
10
+ <a href="hi/LICENSE.md">हिंदी</a> |
11
+ <a href="bn/LICENSE.md">বাংলা</a> |
12
+ <a href="mr/LICENSE.md">मराठी</a> |
13
+ <a href="pa/LICENSE.md">ਪੰਜਾਬੀ</a>
10
14
  </h6>
11
15
  </div>
12
16
 
13
17
  # 🏛️ MIT License
14
18
 
15
- **Copyright © 2024 [Adam Lui](https://github.com/adamlui)**
19
+ **Copyright © 2024 [Adam Lui](https://github.com/adamlui) & contributors**
16
20
 
17
21
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
18
22
 
package/docs/SECURITY.md CHANGED
@@ -6,7 +6,11 @@
6
6
  </picture>
7
7
  &nbsp;English |
8
8
  <a href="zh-cn/SECURITY.md">简体中文</a> |
9
- <a href="zh-tw/SECURITY.md">繁體中文</a>
9
+ <a href="zh-tw/SECURITY.md">繁體中文</a> |
10
+ <a href="hi/SECURITY.md">हिंदी</a> |
11
+ <a href="bn/SECURITY.md">বাংলা</a> |
12
+ <a href="mr/SECURITY.md">मराठी</a> |
13
+ <a href="pa/SECURITY.md">ਪੰਜਾਬੀ</a>
10
14
  </h6>
11
15
  </div>
12
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adamlui/scss-to-css",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "Recursively compile all SCSS files into minified CSS",
5
5
  "author": {
6
6
  "name": "Adam Lui",
@@ -29,17 +29,19 @@
29
29
  },
30
30
  "keywords": [
31
31
  "scss",
32
+ "compiler",
33
+ "minifier",
34
+ "cli",
35
+ "api",
32
36
  "sass",
33
37
  "css",
34
- "stylesheets",
35
- "compiler",
36
- "minifier"
38
+ "stylesheets"
37
39
  ],
38
40
  "bugs": {
39
41
  "url": "https://github.com/adamlui/js-utils/issues"
40
42
  },
41
43
  "dependencies": {
42
- "sass": "^1.71.1"
44
+ "sass": "^1.72.0"
43
45
  },
44
46
  "funding": {
45
47
  "type": "github",
package/scss-to-css.js CHANGED
@@ -13,8 +13,8 @@ function findSCSS(searchDir, options = {}) {
13
13
  const dirFiles = fs.readdirSync(searchDir), scssFiles = [];
14
14
  dirFiles.forEach(file => {
15
15
  const filePath = path.resolve(searchDir, file);
16
- if (fs.statSync(filePath).isDirectory() && file != 'node_modules' &&
17
- (options.dotFolders || !file.startsWith('.')) && options.recursive) {
16
+ if (fs.statSync(filePath).isDirectory() && file != 'node_modules'
17
+ && (options.dotFolders || !file.startsWith('.')) && options.recursive) {
18
18
  if (options.verbose) console.info(`Searching for SCSS files in: ${filePath}...`);
19
19
  scssFiles.push( // recursively find SCSS in eligible dir
20
20
  ...findSCSS(filePath, { ...options, isRecursing: true }));
@@ -22,7 +22,7 @@ function findSCSS(searchDir, options = {}) {
22
22
  scssFiles.push(filePath); // store it for compilation
23
23
  });
24
24
  if (options.isRecursing || scssFiles.length > 0) return scssFiles;
25
- else console.info('\nNo SCSS files found.');
25
+ else if (options.verbose) console.info('\nNo SCSS files found.');
26
26
  }
27
27
 
28
28
  function compile(inputPath, options = {}) {
@@ -40,6 +40,7 @@ function compile(inputPath, options = {}) {
40
40
  return { code: compileResult.css, srcMap: compileResult.sourceMap, srcPath: inputPath };
41
41
  } catch (err) { console.error(`\nERROR: ${ err.message }\n`); return { error: err }; }
42
42
  } else { // dir path passed
43
+ if (options.verbose) console.info('Searching for SCSS files...');
43
44
  return findSCSS(inputPath, { recursive: options.recursive, dotFolders: options.dotFolders })
44
45
  ?.map(scssPath => { // compile found SCSS files
45
46
  if (options.verbose) console.info(`Compiling ${ scssPath }...`);
@@ -124,6 +125,7 @@ else { // run as CLI tool
124
125
  }
125
126
 
126
127
  // Find all eligible JavaScript files or arg-passed file
128
+ printIfNotQuiet('Searching for SCSS files...');
127
129
  const scssFiles = inputArg.endsWith('.scss') ? [inputPath]
128
130
  : findSCSS(inputPath, { recursive: !config.noRecursion });
129
131
 
@@ -132,7 +134,6 @@ else { // run as CLI tool
132
134
  scssFiles?.forEach(file => console.info(file));
133
135
 
134
136
  } else { // actually compile SCSS files
135
- printIfNotQuiet(''); // line break before first log
136
137
 
137
138
  // Build array of compilation data
138
139
  const failedPaths = [];
@@ -1,21 +0,0 @@
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
- &nbsp;简体中文 |
8
- <a href="../LICENSE.md">English</a> |
9
- <a href="../zh-tw/LICENSE.md">繁體中文</a>
10
- </h6>
11
- </div>
12
-
13
- # 🏛️ MIT 许可证
14
-
15
- **版权所有 © 2023–2024 [刘展鹏 (Adam Lui)](https://github.com/adamlui)**
16
-
17
- 特此免费向任何获得副本的人授予许可本软件和相关文档文件(『软件』),处理在软件中不受限制,包括但不限于权利使用、复制、修改、合并、发布、分发、再许可和/或出售该软件的副本,并允许该软件是提供这样做,但须满足以下条件:
18
-
19
- 上述版权声明和本许可声明应包含在所有软件的副本或重要部分。
20
-
21
- 本软件『按原样』提供,不提供任何形式的明示或保证暗示的,包括但不限于适销性保证,适用于特定目的和非侵权。 在任何情况下都不得作者或版权持有人对任何索赔、损害或其他责任,无论是在合同、侵权或其他方面的行为中,由以下原因引起,出于或与软件或使用或其他交易有关软件。
@@ -1,228 +0,0 @@
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
- &nbsp;简体中文 |
8
- <a href="../..#readme">English</a> |
9
- <a href="../zh-tw#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%BD%BD&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
- ```
43
- npm install @adamlui/scss-to-css
44
- ```
45
-
46
- ## 💻 命令行使用
47
-
48
- 基本的**全局命令**是:
49
-
50
- ```
51
- scss-to-css
52
- ```
53
-
54
- 示例输出:
55
-
56
- <img src="https://github.com/adamlui/js-utils/blob/main/scss-to-css/media/images/sample-output.png">
57
-
58
- **💡 笔记:** 默认情况下也会生成源映射,除非传递 `-S` 或 `--no-source-maps`。
59
-
60
- #
61
-
62
- 指定**输入/输出**路径:
63
-
64
- ```
65
- scss-to-css [input_path] [output_path]
66
- ```
67
-
68
- - `[input_path]`: SCSS 文件或包含要编译的 SCSS 文件的目录的路径,相对于当前工作目录。
69
- - `[output_path]`: 将存储 CSS + 源映射文件的文件或目录的路径,相对于原始文件位置(如果未提供,则使用 `css/`)。
70
-
71
- **💡 注意:** 如果传递文件夹,文件将被递归处理,除非传递 `-R` 或 `--no-recursion`。
72
-
73
- #
74
-
75
- 要用作 **包脚本**,请在项目的 `package.json` 中:
76
-
77
- ```json
78
- "scripts": {
79
- "build:css": "<scss-to-css-cmd>"
80
- },
81
- ```
82
-
83
- 将 `<scss-to-css-cmd>` 替换为 `scss-to-css` + 可选参数。 然后,可以使用 `npm run build:css` 来运行该命令。
84
- <br><br>
85
-
86
- ### 命令示例
87
-
88
- 编译 **当前目录** 中的所有 SCSS 文件(输出到 `css/`):
89
-
90
- ```
91
- scss-to-css
92
- ```
93
-
94
- 编译 **特定目录** 中的所有 SCSS 文件(输出到 `path/to/your/directory/css/`):
95
-
96
- ```
97
- scss-to-css path/to/your/directory
98
- ```
99
-
100
- 编译一个**特定文件**(输出到 `path/to/your/css/file.min.css`):
101
-
102
- ```
103
- scss-to-css path/to/your/file.scss
104
- ```
105
-
106
- 指定 **输入和输出** 目录(输出到 `output_folder/`):
107
-
108
- ```
109
- scss-to-css input_folder output_folder
110
- ```
111
-
112
- **💡 注意:** 除非传递 `-M` 或 `--no-minify` ,否则输出 CSS 会被缩小。
113
- <br><br>
114
-
115
- ### 命令行选项
116
-
117
- ```
118
- 配置选项:
119
- -n, --dry-run 实际上并不缩小文件,只是显示它们是否会被处理。
120
- -d, --include-dotfolders 在文件搜索中包括点文件夹。
121
- -S, --no-source-maps 防止生成源映射。
122
- -M, --no-minify 禁用输出 CSS 的缩小。
123
- -R, --no-recursion 禁用递归文件搜索。
124
- -q, --quiet 禁止除错误之外的所有日志记录。
125
-
126
- 信息命令:
127
- -h, --help 显示帮助屏幕。
128
- -v, --version 显示版本号。
129
- ```
130
-
131
- ## 🔌 API 参考
132
-
133
- 您还可以将 **scss-to-css** 导入您的应用程序以使用其 API 方法,无论是作为 ECMAScript 模块还是 CommonJS 模块。
134
-
135
- #### ESM:
136
-
137
- ```js
138
- import * as scssToCSS from '@adamlui/scss-to-css';
139
- ```
140
-
141
- #### CJS:
142
-
143
- ```js
144
- const scssToCSS = require('@adamlui/scss-to-css');
145
- ```
146
-
147
- ### compile(inputPath, options)
148
-
149
- 此函数将在 `inputPath` 中找到的 SCSS 编译为 CSS 数据。
150
-
151
- 如果传递 **文件路径**,则文件的代码将编译为 CSS,然后返回一个包含 `srcPath` + `code` + `error` 的对象:
152
-
153
- ```js
154
- const compileResult = scssToCSS.compile('assets/style.scss');
155
- console.log(compileResult.error); // 运行时错误,如果没有错误则为 `undefined`
156
- console.log(compileResult.code); // 编译后的 assets/style.scss CSS 输出
157
- ```
158
-
159
- 如果传递 **目录路径**,则搜索 SCSS 文件(默认情况下递归),加载每个文件的代码并编译,然后返回包含 `srcPath` + `code` + `error` 的对象数组:
160
-
161
- ```js
162
- const results = scssToCSS.compile('.');
163
- results.forEach(result =>
164
- console.log(result.srcPath) // 工作目录 + 所有嵌套目录中 SCSS 文件的路径
165
- );
166
- console.log(results[1].code); // 如果找到,则编译第二个 SCSS 文件的 CSS 输出,如果未找到,则为 `undefined`
167
- ```
168
-
169
- 选项是布尔值,作为对象属性传递。 例如:
170
-
171
- ```js
172
- scssToCSS.compile(inputDir, { minify: false });
173
- // 返回 `.code` 包含未缩小 CSS 的数据对象
174
- ```
175
-
176
- 可能的参数(及其默认设置)有:
177
-
178
- ```
179
- recursive (true) 如果传递目录路径,则递归搜索嵌套文件。
180
- verbose (true) 在控制台/终端中显示日志记录。
181
- dotFolders (false) 在文件搜索中包括点文件夹。
182
- minify (true) 缩小输出 CSS。
183
- sourceMaps (true) 生成 CSS 源映射。
184
- ```
185
-
186
- ### findSCSS(searchDir, options)
187
-
188
- 此函数搜索传递的 `searchDir` 字符串中的所有 SCSS 文件(对于发现 [`compile()`](#compileinputpath-options) 将处理哪些文件很有用)并返回包含其文件路径的数组。
189
-
190
- 选项是布尔值,作为对象属性传递。 例如:
191
-
192
- ```js
193
- scssToCSS.findSCSS(searchDir, { recursive: false });
194
- // 返回包含恰好位于 `searchDir` 中的 SCSS 文件的文件路径的数组
195
- ```
196
-
197
- 可能的参数(及其默认设置)有:
198
-
199
- ```
200
- recursive (true) 如果传递目录路径,则递归搜索嵌套文件。
201
- verbose (false) 在控制台/终端中显示日志记录。
202
- dotFolders (false) 在文件搜索中包括点文件夹。
203
- ```
204
-
205
- <br>
206
-
207
- ## 💖 支持
208
-
209
- 如果这对您有帮助,请考虑[给予 GitHub ⭐](https://github.com/adamlui/js-utils)!
210
- <br><br>
211
-
212
- ## 🏛️ MIT 许可证
213
-
214
- **版权所有 © 2023–2024 [刘展鹏 (Adam Lui)](https://github.com/adamlui)**
215
-
216
- 特此免费向任何获得副本的人授予许可本软件和相关文档文件(『软件』),处理在软件中不受限制,包括但不限于权利使用、复制、修改、合并、发布、分发、再许可和/或出售该软件的副本,并允许该软件是提供这样做,但须满足以下条件:
217
-
218
- 上述版权声明和本许可声明应包含在所有软件的副本或重要部分。
219
-
220
- 本软件『按原样』提供,不提供任何形式的明示或保证暗示的,包括但不限于适销性保证,适用于特定目的和非侵权。 在任何情况下都不得作者或版权持有人对任何索赔、损害或其他责任,无论是在合同、侵权或其他方面的行为中,由以下原因引起,出于或与软件或使用或其他交易有关软件。
221
-
222
- <br>
223
-
224
- <img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
225
-
226
- <a href="https://github.com/adamlui/js-utils">**家**</a> /
227
- <a href="https://github.com/adamlui/js-utils/discussions">讨论</a> /
228
- <a href="#--scss-to-css">回到顶部 ↑</a>
@@ -1,17 +0,0 @@
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
- &nbsp;简体中文 |
8
- <a href="../SECURITY.md">English</a> |
9
- <a href="../zh-tw/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> 并等待回复后再公开。
@@ -1,21 +0,0 @@
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
- &nbsp;繁體中文 |
8
- <a href="../LICENSE.md">English</a> |
9
- <a href="../zh-cn/LICENSE.md">简体中文</a>
10
- </h6>
11
- </div>
12
-
13
- # 🏛️ MIT 许可证
14
-
15
- **版權所有 © 2023–2024 [刘展鹏 (Adam Lui)](https://github.com/adamlui)**
16
-
17
- 特此免費授予任何取得副本的人許可本軟體和相關文件文件(『軟體』),處理在軟體中不受限制,包括但不限於權利使用、複製、修改、合併、發布、分發、再授權和/或出售該軟體的副本,並允許該軟體是提供這樣做,但須滿足以下條件:
18
-
19
- 上述版權聲明和本許可聲明應包含在所有軟體的副本或重要部分。
20
-
21
- 本軟體『依現況』提供,不提供任何形式的明示或保證暗示的,包括但不限於適銷性保證,適用於特定目的和非侵權。 在任何情況下都不得作者或版權持有人對任何索賠、損害或其他責任,無論是在合約、侵權或其他方面的行為中,由以下原因引起,出於或與軟體或使用或其他交易有關軟體。
@@ -1,227 +0,0 @@
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
- &nbsp;繁體中文 |
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>
@@ -1,17 +0,0 @@
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
- &nbsp;繁體中文 |
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> 並等待回復後再公開。