Skip to content

Commit

Permalink
Build Tools: Integrate DependencyExtractionWebpackPlugin in the JS bu…
Browse files Browse the repository at this point in the history
…ild.

This patch integrates DependencyExtractionWebpackPlugin which was battle-tested in Gutenberg. 

This will greatly simplify the process of upgrading npm packages which change after every Gutenberg release. It might even useful during the WordPress release cycle as we might need to publish more often as we discover critical bugs and regressions.

Props jonsurrell, adamsilverstein, youknowriad, ocean90, netweb.

Fixes #48154. 



git-svn-id: https://develop.svn.wordpress.org/trunk@47035 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
gziolo committed Jan 3, 2020
1 parent c27ab74 commit a35e46a
Show file tree
Hide file tree
Showing 8 changed files with 1,582 additions and 1,226 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ wp-tests-config.php
/src/wp-admin/css/*-rtl.css
/src/wp-admin/css/colors/*/*.css
/src/wp-admin/js
/src/wp-includes/assets
/src/wp-includes/js
/src/wp-includes/css/dist
/src/wp-includes/css/*.min.css
Expand Down
21 changes: 19 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,12 @@ module.exports = function(grunt) {
],
js: [
WORKING_DIR + 'wp-admin/js/',
WORKING_DIR + 'wp-includes/assets/',
WORKING_DIR + 'wp-includes/js/'
],
'webpack-assets': [
WORKING_DIR + 'wp-includes/js/**/*.asset.php'
],
dynamic: {
dot: true,
expand: true,
Expand Down Expand Up @@ -137,6 +141,7 @@ module.exports = function(grunt) {
expand: true,
cwd: SOURCE_DIR,
src: buildFiles.concat( [
'!assets/**', // Assets is extracted into separate copy tasks.
'!js/**', // JavaScript is extracted into separate copy tasks.
'!.{svn,git}', // Exclude version control folders.
'!wp-includes/version.php', // Exclude version.php
Expand Down Expand Up @@ -345,6 +350,12 @@ module.exports = function(grunt) {
}
]
},
'webpack-assets': {
expand: true,
cwd: WORKING_DIR + 'wp-includes/js/',
src: 'dist/*.asset.php',
dest: WORKING_DIR + 'wp-includes/assets/'
},
version: {
options: {
processContent: function( src ) {
Expand Down Expand Up @@ -1350,10 +1361,16 @@ module.exports = function(grunt) {
'uglify:jqueryform'
] );

grunt.registerTask( 'build:js', [
'clean:js',
grunt.registerTask( 'build:webpack', [
'webpack:prod',
'webpack:dev',
'copy:webpack-assets',
'clean:webpack-assets',
] );

grunt.registerTask( 'build:js', [
'clean:js',
'build:webpack',
'copy:js',
'file_append',
'uglify:all',
Expand Down
Loading

0 comments on commit a35e46a

Please sign in to comment.