Giter Club home page Giter Club logo

natours's Introduction

Natours

デザインカンプからWordpressテーマ化までの手順

インストール

npm install

開発手順

gulpの設定ファイルを雛形からコピーする。

cp gulp/config-example.js gulp/config.js

1. 静的サイトの制作

./src以下のファイルを監視して、./static以下に静的サイト用の成果物を出力。

npm run watch:static

読み込むcss, jsファイルの指定

  • ./src/ejs/part/__load_css.html.ejs</head>直前に読み込みたいcssファイルを指定
  • ./src/ejs/part/__load_css.html.ejs</body>直前に読み込みたいjsファイルを指定

画像やフォントの相対パスの指定

ejsやscssファイル中の画像やフォントなどのパスは./src以下の相対パスを指定する。 これは、IDEでのパスの補完を利用するためである。トランスパイル時にパスを自動で修正するので問題はない。

ただし、親ディレクトリの相対パスを指定するときは../から始める。

<img src="../img/xxx.jpg">
body {
  background-image: url(../../img/bg.jpg);
}

ejsファイルの命名

ファイル名のプレフィックスによって、htmlやphpファイルとして出力されるか決まる。

prefix html php
_で始まらない
_が1つのみ
_が2つ続く

開発完了後の出力

開発完了後、./static以下に成果物を出力。

npm run build:static

2. 静的サイトのWordpressテーマ化

WPテーマとして認識させる

ejsファイルを元に./src/php以下にWPテーマ用phpファイルの雛形を出力する。(上書きはしない)

npm run php:init

初回、./wpにテーマ用のファイルを出力する。

npm run build:wp

ローカル環境のWordpressのthemeディレクトリにシンボリックリンクを貼る。

ln -s $(pwd)/wp <themeディレクトリ>/<開発テーマ名>

WPの管理画面で開発テーマを有効化する。

テーマが壊れて認識できない場合は、./wp直下のstyle.cssindex.phpが正しいか確認する。

開発を始める

./gulp/config.js<ローカル環境のWPトップページURL>を置き換える。

module.exports = {
    browserSync: {
        wp: {
            proxy: '<ローカル環境のWPトップページURL>',
        }
    }
};

開発を開始するときに./src以下を監視する。

npm run watch:wp

開発完了後は./wp以下に成果物を出力。

npm run build:wp

natours's People

Contributors

tkda-h3 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.