diff --git .jshintrc .jshintrc
index 0a082dded5..278eac22c3 100644
|
|
|
21 | 21 | "Backbone": false, |
22 | 22 | "jQuery": false, |
23 | 23 | "JSON": false, |
24 | | "wp": false |
| 24 | "wp": false, |
| 25 | "export": false, |
| 26 | "module": false, |
| 27 | "require": false |
25 | 28 | } |
26 | 29 | } |
diff --git Gruntfile.js Gruntfile.js
index 0070a7cf77..e3d0fd2b2d 100644
|
|
|
1 | 1 | /* jshint node:true */ |
| 2 | var webpackConfig = require( './webpack.config' ); |
| 3 | var webpackDevConfig = require( './webpack-dev.config' ); |
| 4 | |
2 | 5 | module.exports = function(grunt) { |
3 | 6 | var path = require('path'), |
4 | 7 | fs = require( 'fs' ), |
5 | 8 | SOURCE_DIR = 'src/', |
6 | 9 | BUILD_DIR = 'build/', |
7 | 10 | BANNER_TEXT = '/*! This file is auto-generated */', |
8 | | autoprefixer = require('autoprefixer'), |
9 | | mediaConfig = {}, |
10 | | mediaBuilds = ['audiovideo', 'grid', 'models', 'views']; |
| 11 | autoprefixer = require( 'autoprefixer' ); |
11 | 12 | |
12 | 13 | // Load tasks. |
13 | 14 | require('matchdep').filterDev(['grunt-*', '!grunt-legacy-util']).forEach( grunt.loadNpmTasks ); |
14 | 15 | // Load legacy utils |
15 | 16 | grunt.util = require('grunt-legacy-util'); |
16 | 17 | |
17 | | mediaBuilds.forEach( function ( build ) { |
18 | | var path = SOURCE_DIR + 'wp-includes/js/media'; |
19 | | mediaConfig[ build ] = { files : {} }; |
20 | | mediaConfig[ build ].files[ path + '-' + build + '.js' ] = [ path + '/' + build + '.manifest.js' ]; |
21 | | } ); |
22 | | |
23 | 18 | // Project configuration. |
24 | 19 | grunt.initConfig({ |
25 | 20 | postcss: { |
… |
… |
module.exports = function(grunt) { |
175 | 170 | } |
176 | 171 | } |
177 | 172 | }, |
178 | | browserify: mediaConfig, |
179 | 173 | sass: { |
180 | 174 | colors: { |
181 | 175 | expand: true, |
… |
… |
module.exports = function(grunt) { |
336 | 330 | ] |
337 | 331 | }, |
338 | 332 | media: { |
339 | | options: { |
340 | | browserify: true |
341 | | }, |
342 | 333 | src: [ |
343 | 334 | SOURCE_DIR + 'wp-includes/js/media/**/*.js' |
344 | 335 | ] |
… |
… |
module.exports = function(grunt) { |
549 | 540 | dest: SOURCE_DIR + 'wp-includes/js/jquery/jquery.masonry.min.js' |
550 | 541 | } |
551 | 542 | }, |
552 | | |
| 543 | webpack: { |
| 544 | options: { |
| 545 | stats: ! process.env.NODE_ENV || 'development' === process.env.NODE_ENV |
| 546 | }, |
| 547 | prod: webpackConfig, |
| 548 | dev: Object.assign( { watch: true }, webpackDevConfig ) |
| 549 | }, |
553 | 550 | concat: { |
554 | 551 | tinymce: { |
555 | 552 | options: { |
… |
… |
module.exports = function(grunt) { |
732 | 729 | } |
733 | 730 | }, |
734 | 731 | config: { |
735 | | files: 'Gruntfile.js' |
| 732 | files: [ |
| 733 | 'Gruntfile.js', |
| 734 | 'webpack-dev.config.js', |
| 735 | 'webpack.config.js' |
| 736 | ] |
736 | 737 | }, |
737 | 738 | colors: { |
738 | 739 | files: [SOURCE_DIR + 'wp-admin/css/colors/**'], |
… |
… |
module.exports = function(grunt) { |
770 | 771 | |
771 | 772 | // Register tasks. |
772 | 773 | |
| 774 | // Webpack task. |
| 775 | grunt.loadNpmTasks( 'grunt-webpack' ); |
| 776 | |
773 | 777 | // RTL task. |
774 | 778 | grunt.registerTask('rtl', ['rtlcss:core', 'rtlcss:colors']); |
775 | 779 | |
… |
… |
module.exports = function(grunt) { |
793 | 797 | grunt.renameTask( 'watch', '_watch' ); |
794 | 798 | |
795 | 799 | grunt.registerTask( 'watch', function() { |
796 | | if ( ! this.args.length || this.args.indexOf( 'browserify' ) > -1 ) { |
797 | | grunt.config( 'browserify.options', { |
798 | | browserifyOptions: { |
799 | | debug: true |
800 | | }, |
801 | | watch: true |
802 | | } ); |
| 800 | if ( ! this.args.length || this.args.indexOf( 'webpack' ) > -1 ) { |
803 | 801 | |
804 | | grunt.task.run( 'browserify' ); |
| 802 | grunt.task.run( 'webpack:dev' ); |
805 | 803 | } |
806 | 804 | |
807 | 805 | grunt.task.run( '_' + this.nameArgs ); |
… |
… |
module.exports = function(grunt) { |
812 | 810 | ] ); |
813 | 811 | |
814 | 812 | grunt.registerTask( 'precommit:js', [ |
815 | | 'browserify', |
| 813 | 'webpack:prod', |
816 | 814 | 'jshint:corejs', |
817 | 815 | 'uglify:bookmarklet', |
818 | 816 | 'uglify:masonry', |
… |
… |
module.exports = function(grunt) { |
881 | 879 | return regex.test( result.stdout ); |
882 | 880 | } |
883 | 881 | |
884 | | if ( [ 'package.json', 'Gruntfile.js' ].some( testPath ) ) { |
| 882 | if ( [ 'package.json', 'Gruntfile.js', 'webpack.config.js' ].some( testPath ) ) { |
885 | 883 | grunt.log.writeln( 'Configuration files modified. Running `prerelease`.' ); |
886 | 884 | taskList.push( 'prerelease' ); |
887 | 885 | } else { |
… |
… |
module.exports = function(grunt) { |
979 | 977 | grunt.event.on('watch', function( action, filepath, target ) { |
980 | 978 | var src; |
981 | 979 | |
982 | | if ( [ 'all', 'rtl', 'browserify' ].indexOf( target ) === -1 ) { |
| 980 | if ( [ 'all', 'rtl', 'webpack' ].indexOf( target ) === -1 ) { |
983 | 981 | return; |
984 | 982 | } |
985 | 983 | |
diff --git package.json package.json
index 8ffb450645..fb13e0fdf4 100644
|
|
|
15 | 15 | "autoprefixer": "^6.5.1", |
16 | 16 | "grunt": "~0.4.5", |
17 | 17 | "grunt-banner": "^0.6.0", |
18 | | "grunt-browserify": "~5.0.0", |
19 | 18 | "grunt-contrib-clean": "~1.0.0", |
20 | 19 | "grunt-contrib-compress": "~1.3.0", |
21 | 20 | "grunt-contrib-concat": "~1.0.0", |
… |
… |
|
34 | 33 | "grunt-replace": "~1.0.1", |
35 | 34 | "grunt-rtlcss": "~2.0.1", |
36 | 35 | "grunt-sass": "~1.2.1", |
37 | | "matchdep": "~1.0.0" |
| 36 | "grunt-webpack": "^3.0.2", |
| 37 | "matchdep": "~1.0.0", |
| 38 | "webpack": "^3.5.4", |
| 39 | "webpack-dev-server": "^2.7.1" |
38 | 40 | } |
39 | 41 | } |
diff --git webpack-dev.config.js webpack-dev.config.js
new file mode 100644
index 0000000000..1c550f7348
-
|
+
|
|
| 1 | var path = require('path'), |
| 2 | SOURCE_DIR = 'src/', |
| 3 | mediaConfig = {}, |
| 4 | mediaBuilds = ['audiovideo', 'grid', 'models', 'views'], |
| 5 | webpack = require('webpack'); |
| 6 | |
| 7 | |
| 8 | mediaBuilds.forEach( function ( build ) { |
| 9 | var path = SOURCE_DIR + 'wp-includes/js/media'; |
| 10 | mediaConfig[ build ] = './' + path + '/' + build + '.manifest.js'; |
| 11 | } ); |
| 12 | |
| 13 | module.exports = { |
| 14 | cache: true, |
| 15 | entry: mediaConfig, |
| 16 | output: { |
| 17 | path: path.join( __dirname, 'src/wp-includes/js' ), |
| 18 | filename: 'media-[name].js' |
| 19 | } |
| 20 | } |
diff --git webpack.config.js webpack.config.js
new file mode 100644
index 0000000000..eb7c964d5a
-
|
+
|
|
| 1 | var path = require('path'), |
| 2 | SOURCE_DIR = 'src/', |
| 3 | mediaConfig = {}, |
| 4 | mediaBuilds = ['audiovideo', 'grid', 'models', 'views'], |
| 5 | webpack = require('webpack'); |
| 6 | |
| 7 | |
| 8 | mediaBuilds.forEach( function ( build ) { |
| 9 | var path = SOURCE_DIR + 'wp-includes/js/media'; |
| 10 | mediaConfig[ build ] = './' + path + '/' + build + '.manifest.js'; |
| 11 | } ); |
| 12 | |
| 13 | module.exports = { |
| 14 | cache: true, |
| 15 | entry: mediaConfig, |
| 16 | output: { |
| 17 | path: path.join( __dirname, 'src/wp-includes/js' ), |
| 18 | filename: 'media-[name].js' |
| 19 | }, |
| 20 | plugins: [ |
| 21 | new webpack.optimize.ModuleConcatenationPlugin() |
| 22 | ] |
| 23 | } |