Skip to content

Commit

Permalink
updated dependencies
Browse files Browse the repository at this point in the history
improved build performance
  • Loading branch information
nk-o committed Oct 1, 2018
1 parent c4f88b2 commit 231ab1f
Show file tree
Hide file tree
Showing 9 changed files with 4,130 additions and 4,861 deletions.
4 changes: 2 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"presets": [
[ "env", {
[ "@babel/preset-env", {
"modules": false,
"targets": {
"browsers": [
Expand All @@ -19,6 +19,6 @@
[ "transform-react-jsx", {
"pragma": "wp.element.createElement"
} ],
[ "transform-object-rest-spread" ]
[ "@babel/plugin-proposal-object-rest-spread" ]
]
}
8 changes: 3 additions & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
"extends": [
"wordpress",
"plugin:react/recommended",
"plugin:jsx-a11y/recommended",
"plugin:jest/recommended"
"plugin:jsx-a11y/recommended"
],
"env": {
"browser": false,
"es6": true,
"node": true,
"mocha": true,
"jest/globals": true
"mocha": true
},
"parserOptions": {
"sourceType": "module",
Expand All @@ -27,7 +25,7 @@
"window": true,
"document": true
},
"plugins": ["react", "jsx-a11y", "jest"],
"plugins": ["react", "jsx-a11y"],
"settings": {
"react": {
"pragma": "wp"
Expand Down
38 changes: 22 additions & 16 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const production_config = template(data.gulp_config.production);

const dist = templateVars.dist;

let isDev = false;

// run streams for each of theme items (theme and plugins)
function runStream (arr, func) {
var streams = merge();
Expand Down Expand Up @@ -75,7 +77,7 @@ gulp.task('build_blocks_js', function () {
return gulp.src(itemData.from + '/blocks/index.jsx')
.pipe($.plumber({ errorHandler }))
.pipe(named())
.pipe(webpack(webpackconfig))
.pipe(webpack(webpackconfig(isDev)))
.pipe($.rename({
suffix: '.min'
}))
Expand All @@ -88,8 +90,9 @@ gulp.task('build_js', function () {
.pipe($.plumber({ errorHandler }))
.pipe(named())
.pipe(webpack({
mode: isDev ? 'development' : 'production',
module: {
loaders: [
rules: [
{
test: /.js$/,
loader: 'babel-loader',
Expand All @@ -98,11 +101,6 @@ gulp.task('build_js', function () {
],
},
}))
.pipe($.uglify({
output: {
comments: /^!/
}
}))
.pipe($.rename({
suffix: '.min'
}))
Expand Down Expand Up @@ -228,15 +226,23 @@ gulp.task('watch_build_vendors', function(cb) {
/**
* Watch Task
*/
gulp.task('watch', ['build'], function() {
for (var k = 0; k < work_folders.length; k++) {
var itemData = work_folders[k];
gulp.watch([itemData.from + '/**/*.php', '!' + itemData.from + '/*vendor/**/*'], ['watch_build_php']);
gulp.watch([itemData.from + '/**/*.{js,jsx}', '!' + itemData.from + '/*vendor/**/*'], ['build_blocks_js', 'build_js']);
gulp.watch([itemData.from + '/**/*.scss', '!' + itemData.from + '/*vendor/**/*'], ['build_scss', 'build_blocks_js']);
gulp.watch([itemData.from + '/**/*', '!' + itemData.from + '/**/*.{php,js,jsx,scss}', itemData.from + '/*vendor/**/*'], ['watch_build_all']);
gulp.watch(itemData.from + '/**/vendor/**/*', ['watch_build_vendors']);
}
gulp.task('watch', function() {
isDev = true;
runSequence(
'build',
function() {
for (var k = 0; k < work_folders.length; k++) {
var itemData = work_folders[k];
gulp.watch([itemData.from + '/**/*.php', '!' + itemData.from + '/*vendor/**/*'], ['watch_build_php']);
gulp.watch([itemData.from + '/**/*.{js,jsx}', '!' + itemData.from + '/*vendor/**/*'], () => {
runSequence('build_blocks_js', 'build_js');
});
gulp.watch([itemData.from + '/**/*.scss', '!' + itemData.from + '/*vendor/**/*'], ['build_scss', 'build_blocks_js']);
gulp.watch([itemData.from + '/**/*', '!' + itemData.from + '/**/*.{php,js,jsx,scss}', itemData.from + '/*vendor/**/*'], ['watch_build_all']);
gulp.watch(itemData.from + '/**/vendor/**/*', ['watch_build_vendors']);
}
}
);
});


Expand Down
Loading

0 comments on commit 231ab1f

Please sign in to comment.