日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

在Grails 2.3.X中使用sass脚本

發(fā)布時(shí)間:2023/12/31 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 在Grails 2.3.X中使用sass脚本 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Sass是可用的最成熟,穩(wěn)定和強(qiáng)大的專業(yè)級(jí)CSS擴(kuò)展語(yǔ)言之一。 在使用Sass之前,我們需要在項(xiàng)目中進(jìn)行設(shè)置。

在grails-2.4.X中,通過(guò)資產(chǎn)管道插件很容易使用sass。 但是對(duì)于grails-2.3.x版本,我們需要遵循以下步驟:

步驟1

使用RVM安裝Ruby :

curl -sSL https://get.rvm.io | bash -s stable --rails source ~/.rvm/scripts/rvm rvm install ruby-2.1.2 rvm list

在以上命令中,我們正在使用“ RVM”安裝“ Ruby”。

第2步

安裝捆綁包和指南針寶石:

sudo apt-get install gem gem install bundle bundle -v gem install compass

Bundler是Rails 3的默認(rèn)gem管理器,盡管它可以與任何Ruby項(xiàng)目一起使用,因?yàn)樗灰蕾囉诳蚣堋?

第三步

在項(xiàng)目的根文件夾下添加了名為“ Gemfile”的新文件,其內(nèi)容如下:

source 'https://rubygems.org'gem 'compass', '~> 0.13.alpha.0'group :development dogem 'guard'gem 'guard-shell' end

這樣可以確保Gemfile中指定的所有g(shù)em及其依賴關(guān)系都可用于您的應(yīng)用程序。

第四步

項(xiàng)目的內(nèi)部腳本文件夾:

bundle install

運(yùn)行“捆綁安裝”將生成一個(gè)Gemfile.lock文件,該文件應(yīng)添加到您的git存儲(chǔ)庫(kù)中。 Gemfile.lock確保您在Heroku上部署的gem版本與開發(fā)計(jì)算機(jī)上本地安裝的版本匹配。

第5步

在scripts目錄下創(chuàng)建一個(gè)名為'compass-compile'的新腳本文件,其內(nèi)容如下:

#!/bin/shSTYLE="compact"if [ $1 ] thenSTYLE=$1 ficd $2 bundle exec compass compile --force --output-style $STYLE --environment production --css-dir web-app/css --sass-dir src/sass --images-dir web-app/images/

在這里,在此腳本中,我們將“ sass”文件編譯為“ css”文件。

第6步

在腳本目錄下創(chuàng)建一個(gè)新的_Events.groovy文件,其內(nèi)容如下:

import grails.util.Environment eventCompileEnd = {x ->if(Environment.currentEnvironment!=Environment.TEST) {compileSass()} }def compileSass() {def baseDir = System.getProperty("base.dir")def commandif(baseDir != null) {command = """${baseDir}/scripts/compass-compile compact ${baseDir}"""// Create the String} else {command = """scripts/compass-compile compact ."""// Create the String}def proc = command.execute() // Call *execute* on the stringproc.waitFor() // Wait for the command to finishif(proc.exitValue() == 0) {def messages = proc.in.text.split("\n")messages.each { message ->event("StatusUpdate",[message])}} else {event("StatusError", ["Problem compiling SASS ${proc.err.text}"])} }

當(dāng)我們運(yùn)行g(shù)rails應(yīng)用程序時(shí),將調(diào)用'compileSass()'函數(shù)。 此功能使用步驟5中指定的腳本將“ sass”文件編譯為“ css”文件。

步驟7

將您的sass文件添加到“ src / sass”目錄下。 上面的腳本將“ src / sass”目錄下的所有sass文件轉(zhuǎn)換為css文件,并將其復(fù)制到wep-app / css目錄中。

  • 我也為此創(chuàng)建了一個(gè)演示應(yīng)用程序 。

希望能幫助到你!

翻譯自: https://www.javacodegeeks.com/2015/02/working-with-sass-scripts-in-grails-2-3-x.html

總結(jié)

以上是生活随笔為你收集整理的在Grails 2.3.X中使用sass脚本的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。