diff --git Gruntfile.js Gruntfile.js
index c7e7f73b2b..ba02c875c6 100644
|
|
|
|
| 1 | 1 | /* jshint node:true */ |
| | 2 | const webpackConfig = require( './webpack.config' ); |
| | 3 | |
| 2 | 4 | module.exports = function(grunt) { |
| 3 | 5 | var path = require('path'), |
| 4 | 6 | fs = require( 'fs' ), |
| 5 | 7 | SOURCE_DIR = 'src/', |
| 6 | 8 | BUILD_DIR = 'build/', |
| 7 | | autoprefixer = require('autoprefixer'), |
| 8 | | mediaConfig = {}, |
| 9 | | mediaBuilds = ['audiovideo', 'grid', 'models', 'views']; |
| | 9 | autoprefixer = require( 'autoprefixer' ); |
| 10 | 10 | |
| 11 | 11 | // Load tasks. |
| 12 | 12 | require('matchdep').filterDev(['grunt-*', '!grunt-legacy-util']).forEach( grunt.loadNpmTasks ); |
| 13 | 13 | // Load legacy utils |
| 14 | 14 | grunt.util = require('grunt-legacy-util'); |
| 15 | 15 | |
| 16 | | mediaBuilds.forEach( function ( build ) { |
| 17 | | var path = SOURCE_DIR + 'wp-includes/js/media'; |
| 18 | | mediaConfig[ build ] = { files : {} }; |
| 19 | | mediaConfig[ build ].files[ path + '-' + build + '.js' ] = [ path + '/' + build + '.manifest.js' ]; |
| 20 | | } ); |
| 21 | | |
| 22 | 16 | // Project configuration. |
| 23 | 17 | grunt.initConfig({ |
| 24 | 18 | postcss: { |
| … |
… |
module.exports = function(grunt) { |
| 157 | 151 | } |
| 158 | 152 | } |
| 159 | 153 | }, |
| 160 | | browserify: mediaConfig, |
| 161 | 154 | sass: { |
| 162 | 155 | colors: { |
| 163 | 156 | expand: true, |
| … |
… |
module.exports = function(grunt) { |
| 318 | 311 | ] |
| 319 | 312 | }, |
| 320 | 313 | media: { |
| 321 | | options: { |
| 322 | | browserify: true |
| 323 | | }, |
| 324 | 314 | src: [ |
| 325 | 315 | SOURCE_DIR + 'wp-includes/js/media/**/*.js' |
| 326 | 316 | ] |
| … |
… |
module.exports = function(grunt) { |
| 531 | 521 | dest: SOURCE_DIR + 'wp-includes/js/jquery/jquery.masonry.min.js' |
| 532 | 522 | } |
| 533 | 523 | }, |
| 534 | | |
| | 524 | webpack: { |
| | 525 | options: { |
| | 526 | stats: ! process.env.NODE_ENV || process.env.NODE_ENV === 'development' |
| | 527 | }, |
| | 528 | prod: webpackConfig, |
| | 529 | dev: Object.assign( { watch: true }, webpackConfig) |
| | 530 | }, |
| 535 | 531 | concat: { |
| 536 | 532 | tinymce: { |
| 537 | 533 | options: { |
| … |
… |
module.exports = function(grunt) { |
| 661 | 657 | |
| 662 | 658 | // Register tasks. |
| 663 | 659 | |
| | 660 | // Webpack tash. |
| | 661 | grunt.loadNpmTasks( 'grunt-webpack' ); |
| | 662 | |
| 664 | 663 | // RTL task. |
| 665 | 664 | grunt.registerTask('rtl', ['rtlcss:core', 'rtlcss:colors']); |
| 666 | 665 | |
| … |
… |
module.exports = function(grunt) { |
| 684 | 683 | grunt.renameTask( 'watch', '_watch' ); |
| 685 | 684 | |
| 686 | 685 | grunt.registerTask( 'watch', function() { |
| 687 | | if ( ! this.args.length || this.args.indexOf( 'browserify' ) > -1 ) { |
| 688 | | grunt.config( 'browserify.options', { |
| 689 | | browserifyOptions: { |
| 690 | | debug: true |
| 691 | | }, |
| 692 | | watch: true |
| 693 | | } ); |
| | 686 | if ( ! this.args.length || this.args.indexOf( 'webpack' ) > -1 ) { |
| 694 | 687 | |
| 695 | | grunt.task.run( 'browserify' ); |
| | 688 | grunt.task.run( 'webpack' ); |
| 696 | 689 | } |
| 697 | 690 | |
| 698 | 691 | grunt.task.run( '_' + this.nameArgs ); |
| … |
… |
module.exports = function(grunt) { |
| 703 | 696 | ] ); |
| 704 | 697 | |
| 705 | 698 | grunt.registerTask( 'precommit:js', [ |
| 706 | | 'browserify', |
| | 699 | 'webpack', |
| 707 | 700 | 'jshint:corejs', |
| 708 | 701 | 'uglify:bookmarklet', |
| 709 | 702 | 'uglify:masonry', |
| … |
… |
module.exports = function(grunt) { |
| 860 | 853 | grunt.event.on('watch', function( action, filepath, target ) { |
| 861 | 854 | var src; |
| 862 | 855 | |
| 863 | | if ( [ 'all', 'rtl', 'browserify' ].indexOf( target ) === -1 ) { |
| | 856 | if ( [ 'all', 'rtl', 'webpack' ].indexOf( target ) === -1 ) { |
| 864 | 857 | return; |
| 865 | 858 | } |
| 866 | 859 | |
diff --git package.json package.json
index 047d5fc35d..3516101ac2 100644
|
|
|
|
| 33 | 33 | "grunt-rtlcss": "~2.0.1", |
| 34 | 34 | "grunt-sass": "~1.2.1", |
| 35 | 35 | "matchdep": "~1.0.0" |
| | 36 | }, |
| | 37 | "dependencies": { |
| | 38 | "grunt-webpack": "^3.0.0", |
| | 39 | "webpack": "^2.6.1", |
| | 40 | "webpack-dev-server": "^2.5.0" |
| 36 | 41 | } |
| 37 | 42 | } |
diff --git webpack.config.js webpack.config.js
new file mode 100644
index 0000000000..d503a39abf
|
-
|
+
|
|
| | 1 | var path = require('path'), |
| | 2 | SOURCE_DIR = 'src/', |
| | 3 | mediaConfig = {}, |
| | 4 | mediaBuilds = ['audiovideo', 'grid', 'models', 'views']; |
| | 5 | |
| | 6 | |
| | 7 | mediaBuilds.forEach( function ( build ) { |
| | 8 | var path = SOURCE_DIR + 'wp-includes/js/media'; |
| | 9 | mediaConfig[ build ] = './' + path + '/' + build + '.manifest.js'; |
| | 10 | } ); |
| | 11 | |
| | 12 | module.exports = { |
| | 13 | entry: mediaConfig, |
| | 14 | output: { |
| | 15 | path: path.join( __dirname, 'src/wp-includes/js' ), |
| | 16 | filename: 'media-[name].js' |
| | 17 | }, |
| | 18 | |
| | 19 | cache: true, |
| | 20 | |
| | 21 | } |