12
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Sageを使うには?WordPressテーマのモダン開発フロー

12
Last updated at Posted at 2019-02-05

2019年の記事

WPを使うなら、スターターテーマの「Sage」を使いたい。
https://roots.io/sage/

これから手順を説明します。

隠しファイル見えるようにする。

定番ですが、最初に設定しておく。

terminal
$ defaults write com.apple.finder AppleShowAllFiles TRUE
$ killall Finder

ディレクトリ名をフルパス表示にしておく。

定番ですが、最初に設定しておく。

terminal
$ defaults write com.apple.finder _FXShowPosixPathInTitle -boolean true
$ killall Finder

Homebrewをインストールする

定番なので、とりあえずインストールする。

terminal
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Node.jsをインストールする

バージョン管理はNodebrew以外にもいろいろありますが、
ここではnodebrewを使います。

terminal
$ brew install nodebrew

nodebrewでバージョン管理

インストールできる

terminal
$ nodebrew install-binary 8.3.0

「そんなディレクトリはありません」といわれる場合は、書き込み権限がない場合がある。
権限設定キチッとやるか、先にフォルダ作っておく。フォルダ作ったほうが早い。

terminal
$ mkdir .nodebrew
$ mkdir .nodebrew/src
$ mkdir .nodebrew/src/v8.3.0

ディレクトリができたら Node.jsをいれていく

terminal
$ nodebrew install-binary 8.3.0

一応、比較用に最新の Node.js も入れておく。

terminal
$ nodebrew install-binary latest

インストールされている Node.js の一覧を見る

terminal
$ nodebrew list
v8.3.0
v11.9.0
current: none

8.3.0を使う場合は?

terminal
$ nodebrew use v8.3.0

バージョンが切り替わっていることを確認する

terminal
$ nodebrew list
v8.3.0
v11.9.0
current: v8.3.0

パスを通す

いちいちディレクトリを書かなくていいように、「パスを通す」という儀式がある。
まずはファイルをつくる。 /User/YourName/ 直下につくります。

terminal
$ touch .bashrc

この .bashrc というファイルをテキストエディタで開く。
これをコピペします。意味は Nodebrew のパスはここを見ますという意味です。

.bashrc
#!/bin/bash
export PATH=$HOME/.nodebrew/current/bin:$PATH

保存する。

terminal
$ source ~/.bashrc

これでパスが通りました。(意味がわかるのに半年くらいかかる)

Yarnを入れる

yarn は「node_modules」のパッケージマネージャです npm でもいいです。

terminal
$ brew install yarn

Composerをインストールする

PHPのパッケージ管理をする。

terminal
$ brew install composer

テーマファイル置く所へ移動する。

この例は MAMP で書いてあります。

terminal
$ cd /Applications/MAMP/htdocs/sample/wp-content/themes

プロジェクトを作る。

composerで作ります。ためしに sage-sample という名前のプロジェクトを作成します。

terminal
$ composer create-project roots/sage sage-sample

このあと、いろいろ対話形式で設定をしていけます。Bootstrap4などを
入れることも可能です。

ビルドする

YARNでコンパイルなどの処理を行います。

terminal
$ cd sage-sample
$ yarn build

これでWordPressテーマの作成が開始できます。
yarnが一連のコンパイル処理を行ってくれるので、Sassで書けます。

12
11
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
12
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?