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 21dc36611d..4a975a8ac0 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) { |
559 | 550 | dest: SOURCE_DIR + 'wp-includes/js/jquery/jquery.masonry.min.js' |
560 | 551 | } |
561 | 552 | }, |
562 | | |
| 553 | webpack: { |
| 554 | prod: webpackConfig, |
| 555 | dev: webpackDevConfig |
| 556 | }, |
563 | 557 | concat: { |
564 | 558 | tinymce: { |
565 | 559 | options: { |
… |
… |
module.exports = function(grunt) { |
742 | 736 | } |
743 | 737 | }, |
744 | 738 | config: { |
745 | | files: 'Gruntfile.js' |
| 739 | files: [ |
| 740 | 'Gruntfile.js', |
| 741 | 'webpack-dev.config.js', |
| 742 | 'webpack.config.js' |
| 743 | ] |
746 | 744 | }, |
747 | 745 | colors: { |
748 | 746 | files: [SOURCE_DIR + 'wp-admin/css/colors/**'], |
… |
… |
module.exports = function(grunt) { |
780 | 778 | |
781 | 779 | // Register tasks. |
782 | 780 | |
| 781 | // Webpack task. |
| 782 | grunt.loadNpmTasks( 'grunt-webpack' ); |
| 783 | |
783 | 784 | // RTL task. |
784 | 785 | grunt.registerTask('rtl', ['rtlcss:core', 'rtlcss:colors']); |
785 | 786 | |
… |
… |
module.exports = function(grunt) { |
803 | 804 | grunt.renameTask( 'watch', '_watch' ); |
804 | 805 | |
805 | 806 | grunt.registerTask( 'watch', function() { |
806 | | if ( ! this.args.length || this.args.indexOf( 'browserify' ) > -1 ) { |
807 | | grunt.config( 'browserify.options', { |
808 | | browserifyOptions: { |
809 | | debug: true |
810 | | }, |
811 | | watch: true |
812 | | } ); |
| 807 | if ( ! this.args.length || this.args.indexOf( 'webpack' ) > -1 ) { |
813 | 808 | |
814 | | grunt.task.run( 'browserify' ); |
| 809 | grunt.task.run( 'webpack:dev' ); |
815 | 810 | } |
816 | 811 | |
817 | 812 | grunt.task.run( '_' + this.nameArgs ); |
… |
… |
module.exports = function(grunt) { |
822 | 817 | ] ); |
823 | 818 | |
824 | 819 | grunt.registerTask( 'precommit:js', [ |
825 | | 'browserify', |
| 820 | 'webpack:prod', |
826 | 821 | 'jshint:corejs', |
827 | 822 | 'uglify:bookmarklet', |
828 | 823 | 'uglify:masonry', |
… |
… |
module.exports = function(grunt) { |
891 | 886 | return regex.test( result.stdout ); |
892 | 887 | } |
893 | 888 | |
894 | | if ( [ 'package.json', 'Gruntfile.js' ].some( testPath ) ) { |
| 889 | if ( [ 'package.json', 'Gruntfile.js', 'webpack.config.js' ].some( testPath ) ) { |
895 | 890 | grunt.log.writeln( 'Configuration files modified. Running `prerelease`.' ); |
896 | 891 | taskList.push( 'prerelease' ); |
897 | 892 | } else { |
… |
… |
module.exports = function(grunt) { |
989 | 984 | grunt.event.on('watch', function( action, filepath, target ) { |
990 | 985 | var src; |
991 | 986 | |
992 | | if ( [ 'all', 'rtl', 'browserify' ].indexOf( target ) === -1 ) { |
| 987 | if ( [ 'all', 'rtl', 'webpack' ].indexOf( target ) === -1 ) { |
993 | 988 | return; |
994 | 989 | } |
995 | 990 | |
diff --git package.json package.json
index 71695dfb77..10b36c0727 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", |
… |
… |
|
36 | 35 | "grunt-rtlcss": "~2.0.1", |
37 | 36 | "grunt-sass": "~1.2.1", |
38 | 37 | "ink-docstrap": "^1.3.0", |
| 38 | "grunt-webpack": "^3.0.2", |
39 | 39 | "matchdep": "~1.0.0" |
| 40 | "webpack": "^3.5.4", |
| 41 | "webpack-dev-server": "^2.7.1" |
40 | 42 | } |
41 | 43 | } |
diff --git webpack-dev.config.js webpack-dev.config.js
new file mode 100644
index 0000000000..27c8e74b23
-
|
+
|
|
| 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 | watch: true, |
| 16 | entry: mediaConfig, |
| 17 | output: { |
| 18 | path: path.join( __dirname, 'src/wp-includes/js' ), |
| 19 | filename: 'media-[name].js' |
| 20 | } |
| 21 | }; |
diff --git webpack.config.js webpack.config.js
new file mode 100644
index 0000000000..8a0b1e4c5c
-
|
+
|
|
| 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 | }; |