|
1 | | -### Scss/sass简介 |
2 | | - |
3 | | -Scss/Sass 是一款强化 CSS 的辅助工具,它在 CSS 语法的基础上增加了变量 (variables)、嵌套 (nested rules)、混合 (mixins)、导入 (inline imports) 等高级功能,这些拓展令 CSS 更加强大与优雅。 |
4 | | - |
5 | | -使用 Scss/Sass 以及 Scss/Sass 的样式库(如 Compass)有助于更好地组织管理样式文件,以及更高效地开发项目。 |
6 | | - |
7 | | -[scss/sass中文文档](https://www.sass.hk/docs/) |
8 | | - |
9 | | -### 插件安装 |
10 | | - |
11 | | -compile-node-sass插件,编译sass/scss为css。 |
12 | | - |
13 | | -在HBuilderX中,使用`scss/sass`是需要安装`compile-node-sass编译插件`的。 |
14 | | - |
15 | | -安装sass插件,需要到[插件市场](https://ext.dcloud.net.cn/plugin?id=2046)安装。 |
16 | | - |
17 | | -### 插件使用 |
18 | | -- uni-app项目,会自动编译使用sass的文件。 |
19 | | -- 单独编译sass文件。选中sass文件,点击右键菜单 -> 外部命令 -> sass -> 编译scss/sass。 |
20 | | - |
21 | | -<img src="/static/snapshots/tutorial/sass_1.jpeg" /> |
22 | | - |
23 | | -### 配置文件 |
24 | | - |
25 | | -compile-node-sass的配置文件为package.json。 |
26 | | - |
27 | | -点击菜单【工具 -> 插件配置 -> compile-node-sass -> package.json】,即可打开package.json文件。 |
28 | | - |
29 | | -<img src="/static/snapshots/tutorial/sass_2.png" /> |
30 | | - |
31 | | -### 快捷键 |
32 | | - |
33 | | -点击菜单【工具 -> 插件配置 -> compile-node-sass -> package.json】,即可打开配置文件文件。 |
34 | | - |
35 | | -打开package.json, 修改key值,即可配置快捷键;可通过此快捷键直接运行此外部命令。 |
36 | | -比如:`"key": "ctrl + alt + C"` |
| 1 | +### Sass |
| 2 | + |
| 3 | +Sass is a CSS extension that allows you to use variables , nested rules , mixins , inline imports and other functions based on CSS syntax to make CSS more powerful and elegant.. |
| 4 | + |
| 5 | +Using Sass and the Compass style library can help better organize and manage style files and develop projects more efficiently. |
| 6 | + |
| 7 | +[sass docs](http://en.sass.hk/docs/) |
| 8 | + |
| 9 | +### Install |
| 10 | + |
| 11 | +In HBuilderX, the use of `scss/sass` requires the installation of the `compile-node-sass compilation plugin`. |
| 12 | + |
| 13 | +[compile-node-sass Download](https://ext.dcloud.net.cn/plugin?id=2046) |
| 14 | + |
| 15 | +### usage |
| 16 | + |
| 17 | +- The uni-app project will automatically compile files that use sass。 |
| 18 | +- Compile the sass file separately. Select the sass file, click the right-click menu -> external command -> sass -> compile scss/sass. |
| 19 | + |
| 20 | +<img src="/static/snapshots/tutorial/menu_tool/project-explorer_menu_en.png" class="hd-img"/> |
| 21 | + |
| 22 | +### Configuration file |
| 23 | + |
| 24 | +The configuration file of compile-node-sass is package.json. |
| 25 | + |
| 26 | +Click the menu [Tools -> External Command Setting -> compile-node-sass -> package.json] to open the package.json file. |
| 27 | + |
| 28 | +<img src="/static/snapshots/tutorial/menu_tool/menu_sass_en.png" class="hd-img"/> |
| 29 | + |
| 30 | +```json |
| 31 | +{ |
| 32 | + "name": "sass", |
| 33 | + "id": "compile-node-sass", |
| 34 | + "version": "0.0.7", |
| 35 | + "displayName": "%displayName%", |
| 36 | + "description": "%description%", |
| 37 | + "engines": { |
| 38 | + "HBuilderX": "^3.2.6" |
| 39 | + }, |
| 40 | + "external": { |
| 41 | + "type": "node", |
| 42 | + "programPath": "${pluginPath}", |
| 43 | + "executable": "/node_modules/.bin/node-sass", |
| 44 | + "programName": "node-sass-china", |
| 45 | + "commands": [ |
| 46 | + { |
| 47 | + "id": "SASS_COMPILE", |
| 48 | + "name": "%SASS_COMPILE.name%", |
| 49 | + "command": [ |
| 50 | + "${programPath}", |
| 51 | + "${file}", |
| 52 | + "${fileBasename}.css" |
| 53 | + ], |
| 54 | + "extensions": "scss,sass", |
| 55 | + "key": "", |
| 56 | + "showInParentMenu": false, |
| 57 | + "onDidSaveExecution": false |
| 58 | + } |
| 59 | + ] |
| 60 | + }, |
| 61 | + "dependencies": { |
| 62 | + "node-sass-china": "^4.7.2" |
| 63 | + }, |
| 64 | + "extensionDependencies": [ |
| 65 | + "npm" |
| 66 | + ] |
| 67 | +} |
| 68 | + |
| 69 | +``` |
| 70 | +### shortcut keys |
| 71 | + |
| 72 | +Click the menu [Tools -> External Command Setting -> compile-node-sass -> package.json] to open the package.json file. |
| 73 | + |
| 74 | +Open package.json and modify the key value to configure the shortcut key; this external command can be run directly through this shortcut key. |
| 75 | + |
| 76 | +For example: `"key": "ctrl + alt + C"` |
37 | 77 |
|
38 | | -### 保存立即编译 |
| 78 | +### Save and compile now |
39 | 79 |
|
40 | | -点击菜单【工具 -> 插件配置 -> compile-node-sass -> package.json】,即可打开配置文件文件。 |
| 80 | +Click the menu [Tools -> External Command Setting -> compile-node-sass -> package.json] to open the package.json file. |
41 | 81 |
|
42 | | -配置文件中`onDidSaveExecution`,表示保存的时候是否触发编译,默认为false。 |
| 82 | +The `onDidSaveExecution` in the configuration file indicates whether to trigger compilation when saving, and the default is false. |
43 | 83 |
|
44 | | -修改`onDidSaveExecution`为`true`即可。 |
| 84 | +Modify `onDidSaveExecution` to `true`. |
0 commit comments