Make WordPress Core


Ignore:
Timestamp:
12/24/2018 01:28:22 PM (6 years ago)
Author:
atimmer
Message:

Build tools: Allow building WordPress to src.

After the JavaScript reorganization in [43309], it was no longer possible to test WordPress from the src folder. That meant a build step was required to test PHP modifications. That is suboptimal as even a simple copy is slower than a web server just serving the new file.

We achieve building to src by setting a WORKING_DIR constant in the Gruntfile that is build by default, but changes to src when the --dev flag is present on any Grunt command. We provide sensible defaults so some commands, such as copying version.php, always build to build.

Because testing from build is no longer required, we change the messages present in index.php and wp-admin/index.php to be more broadly about building WordPress.

We also change the webpack config to have more straightforward behavior based on the buildTarget argument. It only determines the build target now and has no implicit behavior anymore. grunt build still works as it worked before, to make sure that the build server produces the same wordpress.zip we are used to.

We do all this instead of a symlink setup because symlinks don't work on every platform.

Props omarreiss, netweb, flixos90, SergeyBiryukov.
Fixes #44492.

Location:
trunk/src/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin

    • Property svn:ignore set to
      js
  • trunk/src/wp-admin/index.php

    r43571 r44359  
    22
    33/**
    4  * Note: this file exists only to remind developers to run WordPress from the
    5  * build directory. For the real wp-admin/index.php that gets built and boots
    6  * the WordPress admin, please refer to wp-admin/_index.php.
     4 * Note: this file exists only to remind developers to build the assets.
     5 * For the real wp-admin/index.php that gets built and boots WordPress,
     6 * please refer to wp-admin/_index.php.
    77 */
     8
     9if ( file_exists( dirname( __FILE__ ) . '/../wp-includes/js/dist/edit-post.js' ) ) {
     10    require_once dirname( __FILE__ ) . '/_index.php';
     11    return;
     12}
    813
    914/** Define ABSPATH as this file's directory */
     
    2732// Die with an error message
    2833$die = sprintf(
    29     /* translators: %1$s: WordPress, %2$s: src, %3$s: build */
    30     __( 'You seem to be running %1$s from the %2$s directory. %1$s needs to be built and run from the %3$s directory before we can get started.' ),
    31     'WordPress',
    32     '<code>src</code>',
    33     '<code>build</code>'
    34 ) . '</p>';
    35 $die .= '<p>' . sprintf(
    36     /* translators: %s: WordPress */
    37     __( 'You can build %s by running:' ),
     34    /* translators: %1$s: WordPress */
     35    __( 'You are running %1$s without JavaScript and CSS files. These need to be built.' ),
    3836    'WordPress'
    3937) . '</p>';
    40 $die .= '<p><code>npm install && grunt build</code></p>';
     38
     39$die .= '<p>' . __( 'Before running any grunt tasks you need to make sure the dependencies are installed. You can install these by running ');
     40$die .= '<code style="color: green;">npm install</code>.</p>';
     41
     42$die .= '<ul>';
     43$die .= '<li>' . sprintf(
     44    /* translators: %s: WordPress */
     45        __( 'To build %s while developing run:' ),
     46        'WordPress'
     47    ) . '<br /><br />';
     48$die .= '<code style="color: green;">grunt build --dev</code></li>';
     49$die .= '<li>' . sprintf(
     50        __( 'To build files automatically when changing the source files run:' ),
     51        'WordPress'
     52    ) . '<br /><br />';
     53$die .= '<code style="color: green;">grunt watch</code></li>';
     54$die .= '<li>' . sprintf(
     55        __( 'To create a production build of %s run:' ),
     56        'WordPress'
     57    ) . '<br /><br />';
     58$die .= '<code style="color: green;">grunt build</code></li>';
     59$die .= '</ul>';
     60
     61
    4162$die .= '<p>' . sprintf(
    4263    /* translators: %1$s: NPM URL, %2$s: Grunt URL */
    43     __( 'This requires <a href="%1$s">NPM</a> and <a href="%2$s">Grunt</a>. <a href="%3$s">Read more about setting up your local development environment</a>.' ),
    44     'https://www.npmjs.com/',
    45     'https://gruntjs.com/',
    46     __( 'https://make.wordpress.org/core/handbook/tutorials/installing-wordpress-locally/' )
    47 ) . '</p>';
     64        __( 'This requires <a href="%1$s">NPM</a> and <a href="%2$s">Grunt</a>. <a href="%3$s">Read more about setting up your local development environment</a>.' ),
     65        'https://www.npmjs.com/',
     66        'https://gruntjs.com/',
     67        __( 'https://make.wordpress.org/core/handbook/tutorials/installing-wordpress-locally/' )
     68    ) . '</p>';
    4869
    4970wp_die( $die, __( 'WordPress &rsaquo; Error' ) );
Note: See TracChangeset for help on using the changeset viewer.