Git Product home page Git Product logo

presspack's Introduction

Presspack

Forked from jaredpalmer/presspack to better suit my needs

Features

  • Modern JavaScript through Webpack
  • Live reload via BrowserSync
  • SCSS support
  • Easy dev environments with Docker Compose
  • Stateless, immutable plugin management via Composer
  • Helpful HTML5 Router for firing JS based on Wordpress page slug.
  • Nothing else.

Requirements

  • Node.js
  • Yarn
  • PHP and Composer
  • Docker for Mac / Windows
  • Docker Compose

Getting Started

clone the repository
cd wp-content/themes/theme
yarn install

back to project root:
composer install # if you want plugins ( not required )
docker-compose up 

Wordpress

Get the latest WP from wordpress.org and copy the contents to project root.

Plugins

In composer.json there are few plugins predifined, you might wanna change/remove them. Lean WP strips Wordpress from all the extra stuff, but there's no settings to select which parts you want to remove. For some projects this can be too much.

Theme

There's few example files in theme folder which you might wanna keep or overwrite everything for example with html5blank theme.

Developing Locally

To work on the theme locally, open another window/tab in terminal, go to your theme folder and run:

yarn start

This will open a browser, watch all files (php, scss, js, etc) and reload the browser when you press save.

Building for Production

To create an optimized production build, run:

yarn build

This will minify assets, bundle and uglify javascript, and compile scss to css. It will also add cachebusting names to then ends of the compiled files, so you do not need to bump any enqueued asset versions in functions.php.

Changing ports

There are two ports involved, the port of the dockerized wordpress instance, and the port the Browser Sync runs on. To change the port of the dockerized wordpress instance go into docker-compose.yml and modify ports.

# docker-compose.yml
 ...
  ports:
    - "8080:80" # only need to change `9009:80` --> localhost:9009
 ...

If you want to change the port you develop on (the default is 4000), then open scripts/webpack.config.js and modify BrowserSyncPlugin's port option. If you changed the wordpress port above, be sure to also change proxy accordingly. Don't forget the trailing slash.

// scripts/webpack.config.js
...
new BrowserSyncPlugin({
  notify: false,
  host: 'localhost', 
  port: 4000, // this is the port you develop on. Can be anything.
  logLevel: 'silent',
  files: ['./*.php'],
  proxy: 'http://localhost:8080/', // This port must match docker-compose.yml
}),
...

Project Structure

.
โ”œโ”€โ”€ composer.json                 # Compose dependencies (plugins)
โ”œโ”€โ”€ composer.lock                 # Composer lock file
โ”œโ”€โ”€ docker-compose.yml            # Docker Compose configuration
โ””โ”€โ”€ wp-content
    โ””โ”€โ”€ themes
        โ””โ”€โ”€ theme
            โ”œโ”€โ”€ scripts           # Build / Dev Scripts
            โ”‚   โ”œโ”€โ”€ build.js      # Build task
            โ”‚   โ”œโ”€โ”€ start.js      # Start task
            โ”‚   โ””โ”€โ”€ webpack.config.js # Webpack configuration   
            โ”œโ”€โ”€ src
            โ”‚   โ”œโ”€โ”€ index.js        # JavaScript entry point
            โ”‚   โ”œโ”€โ”€ routes          # Routes
            โ”‚   โ”‚   โ”œโ”€โ”€ common.js   # JS that will run on EVERY page
            โ”‚   โ”‚   โ””โ”€โ”€ <xxx>.js    # JS that will run on pages with <xxx> slug 
            โ”‚   โ”œโ”€โ”€ style.scss      # SCSS style entry point
            โ”‚   โ”œโ”€โ”€ styles          # SCSS
            โ”‚   โ”‚   โ”œโ”€โ”€ _global-vars.scss
            โ”‚   โ”‚   โ”œโ”€โ”€ _base.scss
            โ”‚   โ”‚   โ””โ”€โ”€ ...
            โ”‚   โ””โ”€โ”€ util
            โ”‚       โ”œโ”€โ”€ Router.js    # HTML5 Router, DO NOT TOUCH
            โ”‚       โ””โ”€โ”€ camelCase.js # Helper function for Router, DO NOT TOUCH
            โ”œโ”€โ”€ footer.php
            โ”œโ”€โ”€ functions.php
            โ”œโ”€โ”€ header.php
            โ”œโ”€โ”€ index.php
            โ”œโ”€โ”€ package.json         # Node.js dependencies
            โ””โ”€โ”€ page.php

Original author

presspack's People

Contributors

emiltholin avatar infn8 avatar jaredpalmer avatar turansadri avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.