Build Tools: Add non-minified @wordpress
scripts to the build output.
Props atimmer. Merges [43886] to trunk. See #45156. git-svn-id: https://develop.svn.wordpress.org/trunk@44245 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
61234818ae
commit
caca9cb77b
150
Gruntfile.js
150
Gruntfile.js
@ -12,6 +12,10 @@ module.exports = function(grunt) {
|
|||||||
autoprefixer = require( 'autoprefixer' ),
|
autoprefixer = require( 'autoprefixer' ),
|
||||||
nodesass = require( 'node-sass' ),
|
nodesass = require( 'node-sass' ),
|
||||||
phpUnitWatchGroup = grunt.option( 'group' ),
|
phpUnitWatchGroup = grunt.option( 'group' ),
|
||||||
|
themeFiles = [
|
||||||
|
'wp-content/themes/index.php',
|
||||||
|
'wp-content/themes/twenty*/**'
|
||||||
|
],
|
||||||
buildFiles = [
|
buildFiles = [
|
||||||
'*.php',
|
'*.php',
|
||||||
'*.txt',
|
'*.txt',
|
||||||
@ -19,12 +23,10 @@ module.exports = function(grunt) {
|
|||||||
'wp-includes/**', // Include everything in wp-includes.
|
'wp-includes/**', // Include everything in wp-includes.
|
||||||
'wp-admin/**', // Include everything in wp-admin.
|
'wp-admin/**', // Include everything in wp-admin.
|
||||||
'wp-content/index.php',
|
'wp-content/index.php',
|
||||||
'wp-content/themes/index.php',
|
|
||||||
'wp-content/themes/twenty*/**',
|
|
||||||
'wp-content/plugins/index.php',
|
'wp-content/plugins/index.php',
|
||||||
'wp-content/plugins/hello.php',
|
'wp-content/plugins/hello.php',
|
||||||
'wp-content/plugins/akismet/**'
|
'wp-content/plugins/akismet/**'
|
||||||
],
|
].concat( themeFiles ),
|
||||||
cleanFiles = [],
|
cleanFiles = [],
|
||||||
changedFiles = {
|
changedFiles = {
|
||||||
php: []
|
php: []
|
||||||
@ -127,6 +129,42 @@ module.exports = function(grunt) {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
symlink: {
|
||||||
|
expanded: {
|
||||||
|
files: [
|
||||||
|
{
|
||||||
|
expand: true,
|
||||||
|
overwrite: true,
|
||||||
|
cwd: SOURCE_DIR,
|
||||||
|
src: [
|
||||||
|
'wp-admin/*',
|
||||||
|
'wp-content/uploads/',
|
||||||
|
'wp-content/index.php',
|
||||||
|
'wp-content/plugins/*',
|
||||||
|
'wp-includes/*',
|
||||||
|
'*.php',
|
||||||
|
'*.txt',
|
||||||
|
'*.html',
|
||||||
|
'!wp-load.php',
|
||||||
|
'!wp-admin/css',
|
||||||
|
'!wp-content/themes',
|
||||||
|
'!wp-includes/css',
|
||||||
|
'!wp-includes/version.php', // Exclude version.php
|
||||||
|
'!wp-includes/formatting.php', // Exclude formatting.php
|
||||||
|
'!wp-includes/embed.php', // Exclude formatting.php
|
||||||
|
'!index.php', '!wp-admin/index.php',
|
||||||
|
'!_index.php', '!wp-admin/_index.php'
|
||||||
|
],
|
||||||
|
dest: BUILD_DIR
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'build/wp-config-sample.php': ['wp-config-sample.php'],
|
||||||
|
'build/index.php': ['src/_index.php'],
|
||||||
|
'build/wp-admin/index.php': ['src/wp-admin/_index.php']
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
copy: {
|
copy: {
|
||||||
files: {
|
files: {
|
||||||
files: [
|
files: [
|
||||||
@ -138,6 +176,8 @@ module.exports = function(grunt) {
|
|||||||
'!js/**', // JavaScript is extracted into separate copy tasks.
|
'!js/**', // JavaScript is extracted into separate copy tasks.
|
||||||
'!.{svn,git}', // Exclude version control folders.
|
'!.{svn,git}', // Exclude version control folders.
|
||||||
'!wp-includes/version.php', // Exclude version.php
|
'!wp-includes/version.php', // Exclude version.php
|
||||||
|
'!wp-admin/css/**/*', // Exclude the CSS
|
||||||
|
'!wp-includes/css/**/*', // Exclude the CSS
|
||||||
'!index.php', '!wp-admin/index.php',
|
'!index.php', '!wp-admin/index.php',
|
||||||
'!_index.php', '!wp-admin/_index.php'
|
'!_index.php', '!wp-admin/_index.php'
|
||||||
] ),
|
] ),
|
||||||
@ -153,6 +193,23 @@ module.exports = function(grunt) {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
css: {
|
||||||
|
dot: true,
|
||||||
|
expand: true,
|
||||||
|
cwd: SOURCE_DIR,
|
||||||
|
src: [
|
||||||
|
'wp-admin/**/*.css',
|
||||||
|
'wp-includes/**/*.css'
|
||||||
|
],
|
||||||
|
dest: BUILD_DIR
|
||||||
|
},
|
||||||
|
themes: {
|
||||||
|
dot: true,
|
||||||
|
expand: true,
|
||||||
|
cwd: SOURCE_DIR,
|
||||||
|
src: themeFiles,
|
||||||
|
dest: BUILD_DIR
|
||||||
|
},
|
||||||
'npm-packages': {
|
'npm-packages': {
|
||||||
files: {
|
files: {
|
||||||
'build/wp-includes/js/backbone.js': ['./node_modules/backbone/backbone.js'],
|
'build/wp-includes/js/backbone.js': ['./node_modules/backbone/backbone.js'],
|
||||||
@ -341,6 +398,13 @@ module.exports = function(grunt) {
|
|||||||
src: SOURCE_DIR + 'wp-includes/version.php',
|
src: SOURCE_DIR + 'wp-includes/version.php',
|
||||||
dest: BUILD_DIR + 'wp-includes/version.php'
|
dest: BUILD_DIR + 'wp-includes/version.php'
|
||||||
},
|
},
|
||||||
|
'php-buildFiles': {
|
||||||
|
files: {
|
||||||
|
'build/wp-includes/formatting.php': ['src/wp-includes/formatting.php'],
|
||||||
|
'build/wp-includes/embed.php': ['src/wp-includes/embed.php'],
|
||||||
|
'build/wp-load.php': ['src/wp-load.php'],
|
||||||
|
}
|
||||||
|
},
|
||||||
dynamic: {
|
dynamic: {
|
||||||
dot: true,
|
dot: true,
|
||||||
expand: true,
|
expand: true,
|
||||||
@ -706,6 +770,7 @@ module.exports = function(grunt) {
|
|||||||
},
|
},
|
||||||
webpack: {
|
webpack: {
|
||||||
prod: webpackConfig( { environment: 'production' } ),
|
prod: webpackConfig( { environment: 'production' } ),
|
||||||
|
devProdTarget: webpackConfig( { environment: 'development', forceBuildTarget: 'build/wp-includes' } ),
|
||||||
dev: webpackConfig( { environment: 'development' } ),
|
dev: webpackConfig( { environment: 'development' } ),
|
||||||
watch: webpackConfig( { environment: 'development', watch: true } )
|
watch: webpackConfig( { environment: 'development', watch: true } )
|
||||||
},
|
},
|
||||||
@ -1158,7 +1223,7 @@ module.exports = function(grunt) {
|
|||||||
|
|
||||||
grunt.registerTask( 'watch', function() {
|
grunt.registerTask( 'watch', function() {
|
||||||
if ( ! this.args.length || this.args.indexOf( 'webpack' ) > -1 ) {
|
if ( ! this.args.length || this.args.indexOf( 'webpack' ) > -1 ) {
|
||||||
grunt.task.run( 'build' );
|
grunt.task.run( 'build:dev' );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 'watch:phpunit' === grunt.cli.tasks[ 0 ] || 'undefined' !== typeof grunt.option( 'phpunit' ) ) {
|
if ( 'watch:phpunit' === grunt.cli.tasks[ 0 ] || 'undefined' !== typeof grunt.option( 'phpunit' ) ) {
|
||||||
@ -1307,6 +1372,13 @@ module.exports = function(grunt) {
|
|||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
grunt.registerTask( 'uglify:all', [
|
||||||
|
'uglify:core',
|
||||||
|
'uglify:embed',
|
||||||
|
'uglify:jqueryui',
|
||||||
|
'uglify:imgareaselect'
|
||||||
|
] );
|
||||||
|
|
||||||
grunt.registerTask( 'copy:js', [
|
grunt.registerTask( 'copy:js', [
|
||||||
'copy:npm-packages',
|
'copy:npm-packages',
|
||||||
'copy:vendor-js',
|
'copy:vendor-js',
|
||||||
@ -1314,11 +1386,20 @@ module.exports = function(grunt) {
|
|||||||
'copy:includes-js'
|
'copy:includes-js'
|
||||||
] );
|
] );
|
||||||
|
|
||||||
grunt.registerTask( 'uglify:all', [
|
grunt.registerTask( 'copyOrSymlink', function() {
|
||||||
'uglify:core',
|
var task = grunt.option( 'symlink' ) === true ? 'symlink:expanded' : 'copy:files';
|
||||||
'uglify:embed',
|
grunt.task.run( task );
|
||||||
'uglify:jqueryui',
|
} );
|
||||||
'uglify:imgareaselect'
|
|
||||||
|
grunt.registerTask( 'copy:all', [
|
||||||
|
'copyOrSymlink',
|
||||||
|
'copy:php-buildFiles',
|
||||||
|
'copy:css',
|
||||||
|
'copy:themes',
|
||||||
|
'copy:wp-admin-css-compat-rtl',
|
||||||
|
'copy:wp-admin-css-compat-min',
|
||||||
|
'copy:version',
|
||||||
|
'copy:js'
|
||||||
] );
|
] );
|
||||||
|
|
||||||
grunt.registerTask( 'build:tinymce', [
|
grunt.registerTask( 'build:tinymce', [
|
||||||
@ -1338,16 +1419,26 @@ module.exports = function(grunt) {
|
|||||||
'jsvalidate:build'
|
'jsvalidate:build'
|
||||||
] );
|
] );
|
||||||
|
|
||||||
grunt.registerTask( 'copy:all', [
|
grunt.registerTask( 'clean-all', function() {
|
||||||
'copy:files',
|
if ( grunt.option( 'symlink' ) === true ) {
|
||||||
'copy:wp-admin-css-compat-rtl',
|
// clean all symlinks
|
||||||
'copy:wp-admin-css-compat-min',
|
try {
|
||||||
'copy:version',
|
var delSymlinks = require('del-symlinks');
|
||||||
'copy:js'
|
|
||||||
] );
|
|
||||||
|
|
||||||
grunt.registerTask( 'build', [
|
var result = delSymlinks.sync(['./build/**']);
|
||||||
'clean:all',
|
grunt.log.writeln( '>> ' + result.length + ' symlinks cleaned.' );
|
||||||
|
} catch ( e ) {
|
||||||
|
grunt.verbose.error( 'Error:', e.message );
|
||||||
|
grunt.fail.warn( "Failed to delete symlinks. If you're on Windows, " +
|
||||||
|
"running as administrator could resolve this issue.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
grunt.task.run( 'clean:all' );
|
||||||
|
} );
|
||||||
|
|
||||||
|
grunt.registerTask( 'build:all', [
|
||||||
|
'clean-all',
|
||||||
'copy:all',
|
'copy:all',
|
||||||
'file_append',
|
'file_append',
|
||||||
'cssmin:core',
|
'cssmin:core',
|
||||||
@ -1362,10 +1453,31 @@ module.exports = function(grunt) {
|
|||||||
'includes:embed',
|
'includes:embed',
|
||||||
'usebanner',
|
'usebanner',
|
||||||
'webpack:prod',
|
'webpack:prod',
|
||||||
'webpack:dev',
|
'webpack:devProdTarget',
|
||||||
'jsvalidate:build'
|
'jsvalidate:build'
|
||||||
] );
|
] );
|
||||||
|
|
||||||
|
grunt.registerTask( 'build', function() {
|
||||||
|
grunt.task.run( 'build:all' );
|
||||||
|
} );
|
||||||
|
|
||||||
|
grunt.registerTask( 'build:dev', function() {
|
||||||
|
try {
|
||||||
|
// Try creating a symlink.
|
||||||
|
fs.symlinkSync( './symlink', './symlinktest');
|
||||||
|
grunt.option( 'symlink', true );
|
||||||
|
// If succeeded, remove it again.
|
||||||
|
fs.unlinkSync( './symlinktest' );
|
||||||
|
} catch( e ) {
|
||||||
|
grunt.verbose.error( 'Error:', e.message );
|
||||||
|
grunt.log.error( "Failed to delete symlinks. Falling back to copying " +
|
||||||
|
"files instead. If you're on Windows, " +
|
||||||
|
"running as administrator could resolve this issue.");
|
||||||
|
} finally {
|
||||||
|
grunt.task.run( 'build:all' );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
grunt.registerTask( 'prerelease', [
|
grunt.registerTask( 'prerelease', [
|
||||||
'format:php:error',
|
'format:php:error',
|
||||||
'precommit:php',
|
'precommit:php',
|
||||||
|
@ -49,10 +49,10 @@ function mapVendorCopies( vendors, buildTarget ) {
|
|||||||
} ) );
|
} ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = function( env = { environment: 'production', watch: false } ) {
|
module.exports = function( env = { environment: 'production', watch: false, forceBuildTarget: false } ) {
|
||||||
const mode = env.environment;
|
const mode = env.environment;
|
||||||
const suffix = mode === 'production' ? '.min' : '';
|
const suffix = mode === 'production' ? '.min' : '';
|
||||||
const buildTarget = ( mode === 'production' ? 'build' : 'src' ) + '/wp-includes';
|
const buildTarget = env.forceBuildTarget ? env.forceBuildTarget : ( mode === 'production' ? 'build' : 'src' ) + '/wp-includes';
|
||||||
|
|
||||||
const packages = [
|
const packages = [
|
||||||
'api-fetch',
|
'api-fetch',
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
const mediaConfig = require( './tools/webpack/media' );
|
const mediaConfig = require( './tools/webpack/media' );
|
||||||
const packagesConfig = require( './tools/webpack/packages' );
|
const packagesConfig = require( './tools/webpack/packages' );
|
||||||
|
|
||||||
module.exports = function( env = { environment: "production", watch: false } ) {
|
module.exports = function( env = { environment: "production", watch: false, forceBuildTarget: false } ) {
|
||||||
if ( ! env.watch ) {
|
if ( ! env.watch ) {
|
||||||
env.watch = false;
|
env.watch = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ! env.forceBuildTarget ) {
|
||||||
|
env.forceBuildTarget = false;
|
||||||
|
}
|
||||||
|
|
||||||
const config = [
|
const config = [
|
||||||
mediaConfig( env ),
|
mediaConfig( env ),
|
||||||
packagesConfig( env ),
|
packagesConfig( env ),
|
||||||
|
Loading…
Reference in New Issue
Block a user