Skip to content

Commit

Permalink
Adjust all the build system
Browse files Browse the repository at this point in the history
  • Loading branch information
Copons committed Apr 19, 2019
1 parent 140c6ba commit 7198067
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ jobs:
- run:
name: Build the Full Site Editing plugin and theme
command: |
npx lerna run ci --scope='@automattic/full-site-editing'
npx lerna run build --scope='@automattic/full-site-editing'
cp -R apps/full-site-editing/dist $CIRCLE_ARTIFACTS/full-site-editing/
- store-artifacts-and-test-results

Expand Down
56 changes: 35 additions & 21 deletions apps/full-site-editing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,32 @@ This app contains both the `full-site-editing-plugin` and the required `blank-th

## File Architecture

These is an example of what we should find inside the theme and plugin folders:

```
/blank-theme
/dist
blank-theme.css
blank-theme.js
functions.php
index.js
index.php
index.scss
/full-site-editing-plugin
/dist
full-site-editing-plugin.css
full-site-editing-plugin.js
full-site-editing-plugin.php
index.js
index.scss
```

## Local Development
Symlink both the theme and the plugin into a local WordPress install.

E.g.

```
ln -s ~/Dev/wp-calypso/apps/full-site-editing/full-site-editing-plugin/ ~/Dev/wordpress/wp-content/plugins/full-site-editing-plugin
ln -s ~/Dev/wp-calypso/apps/full-site-editing/blank-theme/ ~/Dev/wordpress/wp-content/themes/blank-theme
/dist
/blank-theme
blank-theme.css
blank-theme.js
functions.php
index.js
index.php
index.scss
/full-site-editing-plugin
full-site-editing-plugin.css
full-site-editing-plugin.js
full-site-editing-plugin.php
index.js
index.scss
```

## Build System
Expand All @@ -47,12 +42,31 @@ Compiles both the theme and the plugin, and watches for changes.
- `npx lerna run build --scope='@automattic/full-site-editing'`<br>
Compiles and minifies for production both the theme and the plugin.

Both these scripts will also move all source and PHP files into their respective folder inside `/dist`.

The entry points are:

- `/blank-theme/index.js`
- `/full-site-editing-plugin/index.js`

The outputs are:

- `/blank-theme/dist/blank-theme.(js|css)`
- `/full-site-editing-plugin/dist/full-site-editing-plugin.(js|css)`
- `/dist/blank-theme`
- `/dist/full-site-editing-plugin`

Note that compiled JS and CSS will have the folder name (e.g. `blank-theme.js`), and will be positioned in the folder root (e.g. `/dist/blank-theme/blank-theme.js`), which is the same level of the main PHP file.<br>
Enqueue your scripts accordingly!

## Local Development

Build (or `run dev`) and symlink both the theme and the plugin into a local WordPress install.

E.g.

```
npx lerna run build --scope='@automattic/full-site-editing'
ln -s ~/Dev/wp-calypso/apps/full-site-editing/dist/full-site-editing-plugin/ ~/Dev/wordpress/wp-content/plugins/full-site-editing-plugin
ln -s ~/Dev/wp-calypso/apps/full-site-editing/dist/blank-theme/ ~/Dev/wordpress/wp-content/themes/blank-theme
```
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ function __construct() {

function register_script_and_style() {
$script_dependencies = json_decode( file_get_contents(
plugin_dir_path( __FILE__ ) . 'dist/full-site-editing-plugin.deps.json'
plugin_dir_path( __FILE__ ) . 'full-site-editing-plugin.deps.json'
), true );
wp_register_script(
'a8c-full-site-editing-script',
plugins_url( 'dist/full-site-editing-plugin.js', __FILE__ ),
plugins_url( 'full-site-editing-plugin.js', __FILE__ ),
is_array( $script_dependencies ) ? $script_dependencies : array(),
filemtime( plugin_dir_path( __FILE__ ) . 'dist/full-site-editing-plugin.js' )
filemtime( plugin_dir_path( __FILE__ ) . 'full-site-editing-plugin.js' )
);

$style_file = is_rtl()
? 'dist/full-site-editing-plugin.rtl.css'
: 'dist/full-site-editing-plugin.css';
? 'full-site-editing-plugin.rtl.css'
: 'full-site-editing-plugin.css';
wp_register_style(
'a8c-full-site-editing-style',
plugins_url( $style_file, __FILE__ ),
Expand Down
7 changes: 3 additions & 4 deletions apps/full-site-editing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@
},
"homepage": "https://github.com/Automattic/wp-calypso",
"scripts": {
"php": "cp -R *plugin *theme dist",
"plugin": "webpack --source='plugin'",
"dev:plugin": "npm run plugin",
"build:plugin": "NODE_ENV=production npm run plugin",
"theme": "webpack --source='theme'",
"dev:theme": "npm run theme",
"build:theme": "NODE_ENV=production npm run theme",
"dev": "npm-run-all --parallel dev:*",
"build": "npm-run-all --parallel build:*",
"php": "cp -R *plugin *theme dist",
"ci": "rimraf dist && npm run build && npm run php"
"dev": "rimraf dist && mkdir dist && npm run php && npm-run-all --parallel dev:*",
"build": "rimraf dist && npm-run-all --parallel build:* && npm run php"
},
"devDependencies": {
"@automattic/calypso-build": "file:../../packages/calypso-build"
Expand Down

0 comments on commit 7198067

Please sign in to comment.