Skip to content

Commit 63fdb02

Browse files
authored
Merge pull request #313 from mziyut/create-pull-request/patch-pull-articles
Pull articles
2 parents f28a244 + 42d21bc commit 63fdb02

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: Tailwind CSS 使用時コンテンツ検出されず必要な css が出力されないとき
3+
tags:
4+
- CSS
5+
- Node.js
6+
- tailwindcss
7+
private: false
8+
updated_at: '2025-05-31T02:48:53+09:00'
9+
id: 9d997055affe984d997b
10+
organization_url_name: foundingbase
11+
slide: false
12+
ignorePublish: false
13+
---
14+
15+
## はじめに
16+
17+
Tailwind CSS には記述されている CSS を検出し、必要な CSS のみ出力されるようになっている。
18+
Tailwind CSS v4 から自動検出されるようになったが v3 以前や 明示的に参照してほしいファイルが有るときに指定する記述がある。
19+
20+
## `@source` について
21+
22+
タイトルの通り検出されなかった場合、 `@source` を明示的に指定することで回避可能である。
23+
Tailwind CSS の Build process から認知されないような `node_modules` 上に無いライブラリやファイル。その他テンプレートファイル `php`, `slim` 等を明示的に指定する。
24+
25+
もし、 `../foo/bar` ディレクトリ配下のファイルを見てほしい場合は以下のように記述すれば良い。
26+
27+
```diff_css:example.css
28+
@import "tailwindcss";
29+
+ @source "../foo/bar/"
30+
```
31+
32+
## Ref
33+
34+
https://tailwindcss.com/docs/functions-and-directives#source-directive
35+
36+
https://tailwindcss.com/docs/detecting-classes-in-source-files
37+
38+
https://tailwindcss.com/docs/installation/framework-guides/laravel/vite
39+
40+
https://flowbite.com/docs/getting-started/vue/
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
title: Ruby で PHP の unserialize 関数で unserialize できる文字列を生成する
3+
tags:
4+
- Ruby
5+
- PHP
6+
- unserialize
7+
- php-serialize
8+
private: false
9+
updated_at: '2025-04-30T23:19:40+09:00'
10+
id: f02d41d1f113abb997cd
11+
organization_url_name: foundingbase
12+
slide: false
13+
ignorePublish: false
14+
---
15+
16+
## はじめに
17+
18+
Ruby Script で、 PHP の `unserialize` 関数を通して使用する文字列を生成したくなった。
19+
Gem `php-serialize` を使うと簡単に扱えたのでそのメモ。
20+
21+
## php-serialize について
22+
23+
https://github.com/jqr/php-serialize
24+
25+
Gemfile 等に `gem 'php-serialize'` を追加した後、下記のように呼び出すことができる。
26+
27+
```rb:example.rb
28+
require 'php-serialize'
29+
30+
PHP.serialize({'foo' => 'bar'}) #=> "a:1:{s:3:\"foo\";s:3:\"bar\";}"
31+
PHP.unserialize('a:1:{s:3:"foo";s:3:"bar";}') #=> {"foo"=>"bar"}
32+
```
33+
34+
## さいごに なぜ `php-serialize` が必要だったか
35+
36+
WordPress の記事等コンテンツのエクスポートファイルである WXR (WordPress eXtended RSS) ファイルの生成に Ruby Script を使用した。
37+
WordPress は PHP で動作する都合上 多くの場所で `serialize`, `unserialize` を実行している。
38+
39+
`serialize` 対象のデータは、実行内容によって変化するような内容であったため、動的に `serialize` できるようにする必要があった。
40+
41+
## Ref
42+
43+
https://github.com/jqr/php-serialize

0 commit comments

Comments
 (0)