Make WordPress theme development great again.
git clone git@github.com:jaredpalmer/presspack.git
yarn install
composer install # if you want plugins ( not required )
docker-compose up
To work on the theme locally, open another window/tab in terminal and run:
yarn start
This will open a browser, watch all files (php, scss, js, etc) and reload thebrowser when you press save.
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 youdo not need to bump any enqueued asset versions in functions.php
.
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 dockerizedWordPress instance go into docker-compose.yml
andmodify ports
.
# docker-compose.yml
...
ports:
- "9009:80" # only need to change `9009:80` --> localhost:9009
...
If you want to change the port you develop on (the default is 4000), then openscripts/webpack.config.js
and modifyBrowserSyncPlugin
'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:9009/', // This port must match docker-compose.yml
}),
...
.
├── composer.json # Compose dependencies (plugins)
├── composer.lock # Composer lock file
├── docker-compose.yml # Docker Compose configuration
├── package.json # Node.js dependencies
├──template # Wordpress PHP theme files
│ ├── footer.php
│ ├── functions.php
│ ├── header.php
│ ├── index.php
│ └── page.php
├──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
Here's how to dump your local database with Docker into a .sql
file
docker exec -it host_db_1 /usr/bin/mysqldump -u username -ppassword database_name > backup.sql
Restore a previous database backup
docker exec -i host_db_1 /usr/bin/mysql -u username -ppassword database_name < backup.sql