Update packages to latest

Removes es6-promise, which is not necessary for local development (we're all on a modern version of node).
Moves the sass file generation to a separate function, the current IIFE method is not clear.
Update autoprefixer's browserlist to use the core WordPress configuration
Add a default task, and map grunt in npm scripts
This commit is contained in:
Kelly Dwan 2019-10-01 16:51:52 -04:00
parent ec4afa649d
commit c8211bf6a0
No known key found for this signature in database
GPG key ID: 8BA5575F3D11575D
3 changed files with 1080 additions and 1169 deletions

View file

@ -1,25 +1,34 @@
/* global module:false, require:function, process:object */
require( 'es6-promise' ).polyfill();
module.exports = function( grunt ) {
var isChild = 'wporg' !== grunt.file.readJSON( 'package.json' ).name;
const getSassFiles = () => {
const files = {};
const paths = [ 'settings', 'tools', 'generic', 'base', 'objects', 'components', 'trumps' ];
paths.forEach( function( component ) {
var paths = [
'../pub/wporg/css/' + component + '/**/*.scss',
'!../pub/wporg/css/' + component + '/_' + component + '.scss'
];
if ( isChild ) {
paths.push( 'css/' + component + '/**/*.scss' );
paths.push( '!css/' + component + '/_' + component + '.scss' );
}
files[ 'css/' + component + '/_' + component + '.scss' ] = paths;
} );
return files;
};
grunt.initConfig({
postcss: {
options: {
map: 'build' !== process.argv[2],
processors: [
require( 'autoprefixer' )( {
browsers: [
'Android >= 2.1',
'Chrome >= 21',
'Edge >= 12',
'Explorer >= 7',
'Firefox >= 17',
'Opera >= 12.1',
'Safari >= 6.0'
],
cascade: false
} ),
require( 'pixrem' ),
@ -51,22 +60,7 @@ module.exports = function( grunt ) {
sass_globbing: {
itcss: {
files: (function() {
var files = {};
['settings', 'tools', 'generic', 'base', 'objects', 'components', 'trumps'].forEach( function( component ) {
var paths = ['../pub/wporg/css/' + component + '/**/*.scss', '!../pub/wporg/css/' + component + '/_' + component + '.scss'];
if ( isChild ) {
paths.push( 'css/' + component + '/**/*.scss' );
paths.push( '!css/' + component + '/_' + component + '.scss' );
}
files[ 'css/' + component + '/_' + component + '.scss' ] = paths;
} );
return files;
}())
files: getSassFiles(),
},
options: { signature: false }
},
@ -89,5 +83,7 @@ module.exports = function( grunt ) {
grunt.loadNpmTasks( 'grunt-contrib-watch' );
grunt.registerTask( 'css', [ 'sass_globbing', 'sass', 'postcss' ] );
grunt.registerTask( 'build', ['css'] );
grunt.registerTask( 'default', [ 'css' ] );
grunt.registerTask( 'build', [ 'css' ] ); // Automatically runs "production" steps
};

File diff suppressed because it is too large Load diff

View file

@ -8,16 +8,24 @@
"type": "git",
"url": "https://github.com/WordPress/five-for-the-future"
},
"scripts": {
"start": "grunt watch",
"build": "grunt build",
"dev": "grunt"
},
"browserslist": [
"extends @wordpress/browserslist-config"
],
"devDependencies": {
"autoprefixer": "^6.3.6",
"cssnano": "^3.7.4",
"es6-promise": "~4.0.5",
"grunt": "^1.0.3",
"grunt-contrib-watch": "^1.1.0",
"grunt-postcss": "^0.8.0",
"grunt-sass": "~3.0.1",
"grunt-sass-globbing": "^1.5.1",
"node-sass": "^4.9.3",
"pixrem": "^3.0.2"
"@wordpress/browserslist-config": "2.6.0",
"autoprefixer": "9.6.1",
"cssnano": "4.1.10",
"grunt": "1.0.4",
"grunt-contrib-watch": "1.1.0",
"grunt-postcss": "0.9.0",
"grunt-sass": "3.1.0",
"grunt-sass-globbing": "1.5.1",
"node-sass": "4.12.0",
"pixrem": "5.0.0"
}
}