0
0

More than 1 year has passed since last update.

SassのインストールとCSSのおまけ知識

Last updated at Posted at 2022-12-17

Dart Sass

インストール

brew install sass/sass/sass

バージョン確認

sass --version
1.50.0

Sassの詳細

sass --version
sass/sass/sass: stable 1.50.0
Stylesheet Preprocessor
https://sass-lang.com
/usr/local/Cellar/sass/1.50.0 (7 files, 8.5MB) *
  Built from source on 2022-04-14 at 10:58:53
From: https://github.com/sass/homebrew-sass/blob/HEAD/sass.rb
==> Dependencies
Build: dart-lang/dart/dart ✔

フォルダ構成

folder
├-css
│	└─style.scss
└-index.html
<!DOCTYPE html>
<html lang="ja">
<head>
中略
  <link rel="stylesheet" href="css/style.css">
  <title>Document</title>
</head>
<body>
  <h1>Dart Sass Test</h1>
  <p>sample text</p>
</body>
</html>
$theme_color: green;

h1, p {
  color: $theme_color;
}

CSSのディレクトリで以下のコマンドを実行

sass style.scss style.css

style.cssとstyle.css.mapが生成される

folder
├-css
│	├-style.css
│	├-style.css.map
│	└─style.scss
└-index.html

スクリーンショット 2022-04-14 17.33.15.png

参照サイト
Sass のインストールと設定(Dart Sass)

スーパリロードなしでもCSSや画像の更新する方法

?v=任意の文字列(日付とか)をファイル名の後ろに追記

?v=20220727

使用例:

<img src="img/book02.jpg?v=20220727">
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0