[英]Github Actions - How to compile SCSS to CSS in CI build time?
I am unsure how people are compiling scss files to css files in Github Actions' CI build time.我不确定人们如何在 Github Actions 的 CI 构建时间中将 scss 文件编译为 css 文件。 Here is my way of doing it.
这是我的做法。 Please let me know if it's the wrong way to approach it.
请让我知道这是否是错误的处理方式。
Here is my github repo: https://github.com/mattfrancis888/gh_actions_heroku这是我的 github 回购: https://github.com/mattfrancis888/gh_actions_heroku
Here is my project directory这是我的项目目录
.github
-> workflows
-> main.yml
src
scss
-> main.scss
-> main.css (untracked in git & not pushed to remote repoistory, it is used locally
; github actions should compile the main.scss file and create a main.css file at CI build time)
package.json
Here is my main.yml , I am following Sass Build Action as the template to convert.scss to.这是我的 main.yml ,我 将 Sass Build Action作为模板转换为 convert.scss 。 css at CI build time.
css 在 CI 构建时。 (SASS Build Action seems to have very little activity & support on it)
(SASS Build Action 似乎很少有活动和支持)
build:
runs-on: ubuntu-latest
steps:
- name: Checkout source Git branch
uses: actions/checkout@v2
with:
ref: main
fetch-depth: 10
submodules: true
- name: Compile CSS from SCSS files
uses: gha-utilities/sass-build@v0.4.7
with:
source: /src/scss/main.scss #I have removed the / in /src and it is still failing
destination: /src/scss/main.css
#deploys to heroku (unrelated to SASS Build Action)
- uses: actions/checkout@v2
- uses: akhileshns/heroku-deploy@v3.12.12 # This is the action
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: "ga" #Must be unique in Heroku
heroku_email: "a88@gmail.com"
When I use SASS to try to compile.scss files to.csss files, I am receiving this error in github action's step at " Compile CSS from SCSS files ":当我使用 SASS 尝试将 .scss 文件编译为 .csss 文件时,我在 github 操作的步骤中收到此错误“从 SCSS 文件编译 CSS ”:
Error: /src/scss/main.scss: no such file or directory
at Object._newRenderError (/home/runner/work/_actions/gha-utilities/sass-build/v0.4.7/node_modules/sass/sass.dart.js:2203:19)
at StaticClosure._renderSync (/home/runner/work/_actions/gha-utilities/sass-build/v0.4.7/node_modules/sass/sass.dart.js:2004:18)
at Object.Primitives_applyFunction (/home/runner/work/_actions/gha-utilities/sass-build/v0.4.7/node_modules/sass/sass.dart.js:6525:30)
at Object.Function_apply (/home/runner/work/_actions/gha-utilities/sass-build/v0.4.7/node_modules/sass/sass.dart.js:13852:16)
at _callDartFunctionFast (/home/runner/work/_actions/gha-utilities/sass-build/v0.4.7/node_modules/sass/sass.dart.js:15558:16)
at Object.renderSync (/home/runner/work/_actions/gha-utilities/sass-build/v0.4.7/node_modules/sass/sass.dart.js:15536:18)
at build_CSS (/home/runner/work/_actions/gha-utilities/sass-build/v0.4.7/index.js:122:28)
at Object.<anonymous> (/home/runner/work/_actions/gha-utilities/sass-build/v0.4.7/index.js:167:5)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10) {
formatted: 'Error: /src/scss/main.scss: no such file or directory',
status: 3
}
From my understanding, main.yml starts with the directory level of package.json.据我了解,main.yml 从 package.json 的目录级别开始。
Did you try to put an.你试过放一个。 before the /?
之前 /? As a dot means from right here go there.
作为一个点意味着从这里 go 那里。 ;-)
;-)
So it would be:所以它会是:
./src/scss/main.scss
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.