8 Star 27 Fork 3

Eno / compile-hero

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Github Page Eno Yao badge version badge install badge rate

English | 中文

特性

1.打开 less, sass, scss, styl, ts, tsx, jade, pugjs 等文件。

2.启动编辑器右下角底部栏开关 Compile Hero: On

Demo

3.按快捷键 (ctrl+s)

或者在文件列表右键菜单选择 Compile Files 命令启动编译,将会在该文件的同级目录 dist 下生成编译后的文件,希望能你远离 webpackgulp 等编译工具繁琐的操作。

Demo Demo

你还可以选中部分代码使用 Compile Selected 菜单项或者快捷键 (ctrl+shift+s),进行代码块的局部编译。

Demo

4.按快捷键 (alt+shift+f) 或者在文件列表右键菜单选择 Format Document 将会帮你自动格式化文件。

Demo

  • 按保存 Ctrl+S 会自动编译编译 less, sass, scss, stylus, typescript, typescriptreact, jade, pug and js 等文件。
  • 支持 less, scss, scss 等文件代码高亮。
  • 支持在默认浏览器打开 html 文件。
  • 支持压缩 javascriptcss 文件。
  • 支持格式化 javascript, json, css, sass, 和 html 等文件。
编译前 编译后
.pug .html
.jade .html
.scss(sass) .css
.less .css
.styl .css
.ts/.tsx .js(JSX)
.js(ES6) .js(ES5)

配置参数

点击插件的配置选项 Extension Settings

点击编辑器底部栏右下角 Compile Hero: On/Off,可以切换不同语言的自动编译开关。

Demo

你可以修改编译后目录和文件的输出位置

Demo

具体参数如下:

是否开启按 (ctrl+s) 时自动编译文件(所有语言的自动编译总开关) 默认值
disable-compile-files-on-did-save-code false
编译失败左下角弹窗提醒开关 默认值
notification-toggle true
配置文件编译后的目录的输出路径 默认值 是否开启按 (ctrl+s) 时自动编译文件 默认值
javascript-output-directory ./dist javascript-output-toggle true
sass-output-directory ./dist sass-output-toggle true
scss-output-directory ./dist scss-output-toggle true
less-output-directory ./dist less-output-toggle true
jade-output-directory ./dist jade-output-toggle true
typescript-output-directory ./dist typescript-output-toggle true
typescriptx-output-directory ./dist typescriptx-output-toggle true
pug-output-directory ./dist pug-output-toggle true
stylus-output-directory ./dist stylus-output-toggle true
generate-minified-html false generate-minified-html-only false
generate-minified-css false generate-minified-css-only false
generate-minified-javascript false generate-minified-javascript-only false

使用 settings.json

在项目根目录下可以新建该目录和文件 .vscode/settings.json 配置高级选项。

这里列举一个 .vscode/settings.json 文件的例子:

{
  "compile-hero": {
    "disable-compile-files-on-did-save-code": false, // 全局开关,false 为开启自动编译, 默认 true 为开启不自动编译
    "notification-toggle": false, // 关闭编译失败时候右下角的弹窗提醒
    "javascript-output-directory": "./out", // javascript 输出的目录
    "javascript-output-toggle": false, // 局部开关,true 为开启 javascript 自动编译,false 为不开启 javascript 自动编译
    "sass-output-directory": "./out", // sass 输出的目录
    "sass-output-toggle": true, // 局部开关,true 为开启 sass 自动编译,false 为不开启 sass 自动编译
    "ignore": ["src/test.js", "*/test.scss", "**/spec/*", "**/src/**/*"], // 禁止文件和文件夹自动格式化和编译
    "watch": ["sass/test.sass", "**/less/**/*"] // 监听对应文件或者文件夹,保存的时候触发编译,一般配合 Compile Hero: On 开关打开使用
  }
}
// 更多配置项:详见下列表格

使用 tsconfig.json

.ts 文件的同级目录创建 tsconfig.json 文件,这个文件可以覆盖 typescript 的默认编译配置。

这里列举一个 .vscode/tsconfig.json 文件的例子:

{
  "compilerOptions": {
    "alwaysStrict": true,
    "importHelpers": false
  }
}

在浏览器预览页面

在目录菜单对着 xxx.html 文件点击右键,会出现 Open In Browser 选项,可以在启动浏览器中预览 xxx.html 该页面。

Demo

关闭端口(仅 MAC)

使用 Close Port 命令可以关闭对应的端口。

Demo

感谢


Eno Yao

Aaron Xie

DK Lan

Yong

Li Ting

Xin

Lemon

Jing

Lin

Tian Fly

如果你觉得有用,希望你可以给我们留言和点赞,你的支持是我们前进的最大动力 😀

协议

遵循 MIT 协议。

The MIT License Copyright (c) 2019-2020 Eno Yao. https://github.com/wscats 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: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

🔰支持在 Visual Studio Code 中自动编译以下文件:Less, Sass, Scss, Typescript, Jade, Pug 和 Jsx 等。 展开 收起
取消

发行版 (2)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/wscats/compile-hero.git
git@gitee.com:wscats/compile-hero.git
wscats
compile-hero
compile-hero
master

搜索帮助

14c37bed 8189591 565d56ea 8189591