├── .babelrc ├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── .nvmrc ├── .stylelintrc.json ├── .travis.yml ├── README.md ├── assets ├── css │ └── example-block.scss └── js │ └── example-block.js ├── composer.json ├── composer.lock ├── geocities-blocks.php ├── package-lock.json ├── package.json ├── phpcs.xml.dist └── webpack.config.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ "@wordpress/babel-preset-default" ], 3 | "plugins": [ 4 | [ "@babel/transform-react-jsx", { 5 | "pragma": "createElement" 6 | } ], 7 | [ 8 | "@wordpress/babel-plugin-import-jsx-pragma", 9 | { 10 | "scopeVariable": "createElement", 11 | "source": "@wordpress/element", 12 | "isDefault": false 13 | } 14 | ] 15 | ] 16 | } -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | build 2 | build-module 3 | coverage 4 | node_modules 5 | vendor 6 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: [ 'plugin:@wordpress/eslint-plugin/recommended' ], 3 | }; 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Editors 2 | project.xml 3 | project.properties 4 | /nbproject/private/ 5 | .buildpath 6 | .project 7 | .settings* 8 | .idea 9 | .vscode 10 | *.sublime-project 11 | *.sublime-workspace 12 | .sublimelinterrc 13 | 14 | # Grunt 15 | /node_modules/ 16 | none 17 | 18 | # Sass 19 | .sass-cache/ 20 | 21 | # OS X metadata 22 | .DS_Store 23 | 24 | # Windows junk 25 | Thumbs.db 26 | 27 | # ApiGen 28 | /wc-apidocs/ 29 | 30 | # Behat/CLI Tests 31 | tests/cli/installer 32 | tests/cli/composer.phar 33 | tests/cli/composer.lock 34 | tests/cli/composer.json 35 | tests/cli/vendor 36 | 37 | # Unit tests 38 | /tmp 39 | /tests/bin/tmp 40 | /tests/e2e-tests/config/local-*.json 41 | 42 | # Logs 43 | /logs 44 | 45 | # Composer 46 | /vendor/ 47 | 48 | # Built files 49 | /build/ 50 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | lts/* 2 | -------------------------------------------------------------------------------- /.stylelintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "stylelint-config-wordpress", 3 | "rules": { 4 | "at-rule-empty-line-before": null, 5 | "at-rule-no-unknown": null, 6 | "comment-empty-line-before": null, 7 | "declaration-block-no-duplicate-properties": null, 8 | "declaration-property-unit-whitelist": null, 9 | "font-weight-notation": null, 10 | "max-line-length": null, 11 | "no-descending-specificity": null, 12 | "no-duplicate-selectors": null, 13 | "rule-empty-line-before": null, 14 | "selector-class-pattern": null, 15 | "value-keyword-case": null 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | dist: xenial 2 | 3 | language: php 4 | 5 | php: 7.1 6 | 7 | notifications: 8 | email: 9 | on_success: never 10 | on_failure: change 11 | 12 | before_install: 13 | - nvm install 14 | 15 | install: 16 | - npm install 17 | - composer install 18 | 19 | script: 20 | - npm run ci 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Geocities Blocks 2 | We're gonna party like it's 1999 3 | 4 | ![Wicked awesome flame separator gif](https://user-images.githubusercontent.com/2846578/50296748-261bf180-0449-11e9-8ba7-63922c37e740.gif) 5 | -------------------------------------------------------------------------------- /assets/css/example-block.scss: -------------------------------------------------------------------------------- 1 | .alignleft { 2 | text-align: left; 3 | } 4 | -------------------------------------------------------------------------------- /assets/js/example-block.js: -------------------------------------------------------------------------------- 1 | /** 2 | * External Dependencies 3 | */ 4 | import { __ } from '@wordpress/i18n'; 5 | import { RawHTML } from '@wordpress/element'; 6 | import { registerBlockType } from '@wordpress/blocks'; 7 | 8 | /** 9 | * Internal dependencies 10 | */ 11 | import '../css/example-block.scss'; 12 | 13 | const Edit = () => { 14 | return
Hello
; 15 | }; 16 | 17 | registerBlockType( 'geocities/example', { 18 | title: __( 'Example Block', 'geocities-blocks' ), 19 | icon: 'star', 20 | category: 'geocities', 21 | description: __( 22 | 'Example block to show how building works.', 23 | 'geocities-blocks' 24 | ), 25 | attributes: { 26 | align: { 27 | type: 'string', 28 | }, 29 | }, 30 | 31 | getEditWrapperProps( attributes ) { 32 | const { align } = attributes; 33 | if ( -1 !== [ 'wide', 'full' ].indexOf( align ) ) { 34 | return { 'data-align': align }; 35 | } 36 | }, 37 | 38 | edit( props ) { 39 | return ; 40 | }, 41 | 42 | save( props ) { 43 | const { 44 | align, 45 | } = props.attributes; /* eslint-disable-line react/prop-types */ 46 | return ( 47 | 48 | BLOCKS 49 | 50 | ); 51 | }, 52 | } ); 53 | 54 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wordpress/gutenberg", 3 | "type": "wordpress-plugin", 4 | "license": "GPL-2.0-or-later", 5 | "description": "Web development like it's 1999.", 6 | "keywords": [ 7 | "gutenberg", "wordpress", "blocks", "geocities" 8 | ], 9 | "support": { 10 | "issues": "https://github.com/melchoyce/geocities-blocks/issues" 11 | }, 12 | "require-dev": { 13 | "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", 14 | "squizlabs/php_codesniffer": "^3.1", 15 | "phpcompatibility/php-compatibility": "^8", 16 | "wp-coding-standards/wpcs": "^1.0.0" 17 | }, 18 | "require": { 19 | "composer/installers": "~1.0" 20 | }, 21 | "scripts": { 22 | "format": "phpcbf --standard=phpcs.xml.dist --report-summary --report-source", 23 | "lint": "phpcs --standard=phpcs.xml.dist" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "b3bfcc5b4198a64dfd48ae9edd6e9210", 8 | "packages": [ 9 | { 10 | "name": "composer/installers", 11 | "version": "v1.6.0", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/composer/installers.git", 15 | "reference": "cfcca6b1b60bc4974324efb5783c13dca6932b5b" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/composer/installers/zipball/cfcca6b1b60bc4974324efb5783c13dca6932b5b", 20 | "reference": "cfcca6b1b60bc4974324efb5783c13dca6932b5b", 21 | "shasum": "" 22 | }, 23 | "require": { 24 | "composer-plugin-api": "^1.0" 25 | }, 26 | "replace": { 27 | "roundcube/plugin-installer": "*", 28 | "shama/baton": "*" 29 | }, 30 | "require-dev": { 31 | "composer/composer": "1.0.*@dev", 32 | "phpunit/phpunit": "^4.8.36" 33 | }, 34 | "type": "composer-plugin", 35 | "extra": { 36 | "class": "Composer\\Installers\\Plugin", 37 | "branch-alias": { 38 | "dev-master": "1.0-dev" 39 | } 40 | }, 41 | "autoload": { 42 | "psr-4": { 43 | "Composer\\Installers\\": "src/Composer/Installers" 44 | } 45 | }, 46 | "notification-url": "https://packagist.org/downloads/", 47 | "license": [ 48 | "MIT" 49 | ], 50 | "authors": [ 51 | { 52 | "name": "Kyle Robinson Young", 53 | "email": "kyle@dontkry.com", 54 | "homepage": "https://github.com/shama" 55 | } 56 | ], 57 | "description": "A multi-framework Composer library installer", 58 | "homepage": "https://composer.github.io/installers/", 59 | "keywords": [ 60 | "Craft", 61 | "Dolibarr", 62 | "Eliasis", 63 | "Hurad", 64 | "ImageCMS", 65 | "Kanboard", 66 | "Lan Management System", 67 | "MODX Evo", 68 | "Mautic", 69 | "Maya", 70 | "OXID", 71 | "Plentymarkets", 72 | "Porto", 73 | "RadPHP", 74 | "SMF", 75 | "Thelia", 76 | "WolfCMS", 77 | "agl", 78 | "aimeos", 79 | "annotatecms", 80 | "attogram", 81 | "bitrix", 82 | "cakephp", 83 | "chef", 84 | "cockpit", 85 | "codeigniter", 86 | "concrete5", 87 | "croogo", 88 | "dokuwiki", 89 | "drupal", 90 | "eZ Platform", 91 | "elgg", 92 | "expressionengine", 93 | "fuelphp", 94 | "grav", 95 | "installer", 96 | "itop", 97 | "joomla", 98 | "kohana", 99 | "laravel", 100 | "lavalite", 101 | "lithium", 102 | "magento", 103 | "majima", 104 | "mako", 105 | "mediawiki", 106 | "modulework", 107 | "modx", 108 | "moodle", 109 | "osclass", 110 | "phpbb", 111 | "piwik", 112 | "ppi", 113 | "puppet", 114 | "pxcms", 115 | "reindex", 116 | "roundcube", 117 | "shopware", 118 | "silverstripe", 119 | "sydes", 120 | "symfony", 121 | "typo3", 122 | "wordpress", 123 | "yawik", 124 | "zend", 125 | "zikula" 126 | ], 127 | "time": "2018-08-27T06:10:37+00:00" 128 | } 129 | ], 130 | "packages-dev": [ 131 | { 132 | "name": "dealerdirect/phpcodesniffer-composer-installer", 133 | "version": "v0.4.4", 134 | "source": { 135 | "type": "git", 136 | "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", 137 | "reference": "2e41850d5f7797cbb1af7b030d245b3b24e63a08" 138 | }, 139 | "dist": { 140 | "type": "zip", 141 | "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/2e41850d5f7797cbb1af7b030d245b3b24e63a08", 142 | "reference": "2e41850d5f7797cbb1af7b030d245b3b24e63a08", 143 | "shasum": "" 144 | }, 145 | "require": { 146 | "composer-plugin-api": "^1.0", 147 | "php": "^5.3|^7", 148 | "squizlabs/php_codesniffer": "*" 149 | }, 150 | "require-dev": { 151 | "composer/composer": "*", 152 | "wimg/php-compatibility": "^8.0" 153 | }, 154 | "suggest": { 155 | "dealerdirect/qa-tools": "All the PHP QA tools you'll need" 156 | }, 157 | "type": "composer-plugin", 158 | "extra": { 159 | "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" 160 | }, 161 | "autoload": { 162 | "psr-4": { 163 | "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" 164 | } 165 | }, 166 | "notification-url": "https://packagist.org/downloads/", 167 | "license": [ 168 | "MIT" 169 | ], 170 | "authors": [ 171 | { 172 | "name": "Franck Nijhof", 173 | "email": "f.nijhof@dealerdirect.nl", 174 | "homepage": "http://workingatdealerdirect.eu", 175 | "role": "Developer" 176 | } 177 | ], 178 | "description": "PHP_CodeSniffer Standards Composer Installer Plugin", 179 | "homepage": "http://workingatdealerdirect.eu", 180 | "keywords": [ 181 | "PHPCodeSniffer", 182 | "PHP_CodeSniffer", 183 | "code quality", 184 | "codesniffer", 185 | "composer", 186 | "installer", 187 | "phpcs", 188 | "plugin", 189 | "qa", 190 | "quality", 191 | "standard", 192 | "standards", 193 | "style guide", 194 | "stylecheck", 195 | "tests" 196 | ], 197 | "time": "2017-12-06T16:27:17+00:00" 198 | }, 199 | { 200 | "name": "phpcompatibility/php-compatibility", 201 | "version": "8.2.0", 202 | "source": { 203 | "type": "git", 204 | "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", 205 | "reference": "eaf613c1a8265bcfd7b0ab690783f2aef519f78a" 206 | }, 207 | "dist": { 208 | "type": "zip", 209 | "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/eaf613c1a8265bcfd7b0ab690783f2aef519f78a", 210 | "reference": "eaf613c1a8265bcfd7b0ab690783f2aef519f78a", 211 | "shasum": "" 212 | }, 213 | "require": { 214 | "php": ">=5.3", 215 | "squizlabs/php_codesniffer": "^2.3 || ^3.0.2" 216 | }, 217 | "conflict": { 218 | "squizlabs/php_codesniffer": "2.6.2" 219 | }, 220 | "require-dev": { 221 | "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0" 222 | }, 223 | "suggest": { 224 | "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.", 225 | "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." 226 | }, 227 | "type": "phpcodesniffer-standard", 228 | "autoload": { 229 | "psr-4": { 230 | "PHPCompatibility\\": "PHPCompatibility/" 231 | } 232 | }, 233 | "notification-url": "https://packagist.org/downloads/", 234 | "license": [ 235 | "LGPL-3.0-or-later" 236 | ], 237 | "authors": [ 238 | { 239 | "name": "Wim Godden", 240 | "role": "lead" 241 | } 242 | ], 243 | "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP version compatibility.", 244 | "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", 245 | "keywords": [ 246 | "compatibility", 247 | "phpcs", 248 | "standards" 249 | ], 250 | "time": "2018-07-17T13:42:26+00:00" 251 | }, 252 | { 253 | "name": "squizlabs/php_codesniffer", 254 | "version": "3.4.0", 255 | "source": { 256 | "type": "git", 257 | "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", 258 | "reference": "379deb987e26c7cd103a7b387aea178baec96e48" 259 | }, 260 | "dist": { 261 | "type": "zip", 262 | "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/379deb987e26c7cd103a7b387aea178baec96e48", 263 | "reference": "379deb987e26c7cd103a7b387aea178baec96e48", 264 | "shasum": "" 265 | }, 266 | "require": { 267 | "ext-simplexml": "*", 268 | "ext-tokenizer": "*", 269 | "ext-xmlwriter": "*", 270 | "php": ">=5.4.0" 271 | }, 272 | "require-dev": { 273 | "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" 274 | }, 275 | "bin": [ 276 | "bin/phpcs", 277 | "bin/phpcbf" 278 | ], 279 | "type": "library", 280 | "extra": { 281 | "branch-alias": { 282 | "dev-master": "3.x-dev" 283 | } 284 | }, 285 | "notification-url": "https://packagist.org/downloads/", 286 | "license": [ 287 | "BSD-3-Clause" 288 | ], 289 | "authors": [ 290 | { 291 | "name": "Greg Sherwood", 292 | "role": "lead" 293 | } 294 | ], 295 | "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", 296 | "homepage": "http://www.squizlabs.com/php-codesniffer", 297 | "keywords": [ 298 | "phpcs", 299 | "standards" 300 | ], 301 | "time": "2018-12-19T23:57:18+00:00" 302 | }, 303 | { 304 | "name": "wp-coding-standards/wpcs", 305 | "version": "1.2.1", 306 | "source": { 307 | "type": "git", 308 | "url": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git", 309 | "reference": "f328bcafd97377e8e5e5d7b244d5ddbf301a3a5c" 310 | }, 311 | "dist": { 312 | "type": "zip", 313 | "url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/f328bcafd97377e8e5e5d7b244d5ddbf301a3a5c", 314 | "reference": "f328bcafd97377e8e5e5d7b244d5ddbf301a3a5c", 315 | "shasum": "" 316 | }, 317 | "require": { 318 | "php": ">=5.3", 319 | "squizlabs/php_codesniffer": "^2.9.0 || ^3.0.2" 320 | }, 321 | "require-dev": { 322 | "phpcompatibility/php-compatibility": "^9.0" 323 | }, 324 | "suggest": { 325 | "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically." 326 | }, 327 | "type": "phpcodesniffer-standard", 328 | "notification-url": "https://packagist.org/downloads/", 329 | "license": [ 330 | "MIT" 331 | ], 332 | "authors": [ 333 | { 334 | "name": "Contributors", 335 | "homepage": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/graphs/contributors" 336 | } 337 | ], 338 | "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions", 339 | "keywords": [ 340 | "phpcs", 341 | "standards", 342 | "wordpress" 343 | ], 344 | "time": "2018-12-18T09:43:51+00:00" 345 | } 346 | ], 347 | "aliases": [], 348 | "minimum-stability": "stable", 349 | "stability-flags": [], 350 | "prefer-stable": false, 351 | "prefer-lowest": false, 352 | "platform": [], 353 | "platform-dev": [] 354 | } 355 | -------------------------------------------------------------------------------- /geocities-blocks.php: -------------------------------------------------------------------------------- 1 | 'geocities-example-block', 36 | 'editor_style' => 'geocities-example-block', 37 | ) 38 | ); 39 | 40 | // Register more blocks here. 41 | } 42 | 43 | /** 44 | * Register the scripts & styles needed. 45 | */ 46 | function geocities_gutenberg_scripts() { 47 | wp_register_script( 48 | 'geocities-example-block', 49 | plugins_url( 'build/example-block.js', __FILE__ ), 50 | array( 'wp-element', 'wp-blocks', 'wp-components', 'wp-i18n' ), 51 | geocities_get_file_version( 'build/example-block.js' ) 52 | ); 53 | wp_register_style( 54 | 'geocities-example-block', 55 | plugins_url( 'build/example-block.css', __FILE__ ), 56 | array(), 57 | geocities_get_file_version( 'build/example-block.css' ) 58 | ); 59 | 60 | // Register more block scripts & styles here. 61 | } 62 | add_action( 'enqueue_block_editor_assets', 'geocities_gutenberg_scripts' ); 63 | 64 | /** 65 | * Get the file modified time if we're using SCRIPT_DEBUG. 66 | * 67 | * @param string $file Local path to the file. 68 | * @return string The cache buster value to use for the given file. 69 | */ 70 | function geocities_get_file_version( $file ) { 71 | if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { 72 | return filemtime( plugin_dir_path( __FILE__ ) . $file ); 73 | } 74 | return GEOCITIES_VERSION; 75 | } 76 | 77 | /** 78 | * Add a new category for Geocities blocks. 79 | * 80 | * @param array $categories The block categories registered. 81 | * @return array The block categories with the geocities category added. 82 | */ 83 | function geocities_register_block_category( $categories ) { 84 | return array_merge( 85 | $categories, 86 | array( 87 | array( 88 | 'slug' => 'geocities', 89 | 'title' => __( 'GeoCities', 'geocities-blocks' ), 90 | ), 91 | ) 92 | ); 93 | } 94 | add_filter( 'block_categories', 'geocities_register_block_category' ); 95 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "geocities-blocks", 3 | "title": "GeoCities Blocks", 4 | "version": "1.0.0", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com:melchoyce/geocities-blocks.git" 8 | }, 9 | "license": "GPL-2.0+", 10 | "engines": { 11 | "node": "10.14.2", 12 | "npm": "6.5.0" 13 | }, 14 | "scripts": { 15 | "build": "cross-env BABEL_ENV=default NODE_ENV=production webpack", 16 | "start": "cross-env BABEL_ENV=default webpack --watch", 17 | "ci": "npm run lint", 18 | "lint": "concurrently \"npm run lint-js\" \"npm run lint-css\" \"npm run lint-php\"", 19 | "lint-js": "eslint . --ext=js,jsx", 20 | "lint-js:fix": "eslint . --ext=js,jsx --fix", 21 | "lint-css": "stylelint '**/*.scss'", 22 | "lint-css:fix": "stylelint '**/*.scss' --fix", 23 | "lint-php": "composer run lint" 24 | }, 25 | "devDependencies": { 26 | "@babel/core": "^7.1.5", 27 | "@wordpress/babel-plugin-import-jsx-pragma": "^1.1.2", 28 | "@wordpress/babel-preset-default": "^3.0.1", 29 | "@wordpress/eslint-plugin": "^1.0.0", 30 | "autoprefixer": "^9.3.1", 31 | "babel-loader": "^8.0.4", 32 | "clean-webpack-plugin": "^0.1.19", 33 | "concurrently": "^4.1.0", 34 | "cross-env": "5.2.0", 35 | "css-loader": "^1.0.1", 36 | "eslint": "^5.9.0", 37 | "mini-css-extract-plugin": "^0.4.4", 38 | "node-sass": "^4.10.0", 39 | "postcss-loader": "^3.0.0", 40 | "sass-loader": "^7.1.0", 41 | "style-loader": "^0.23.1", 42 | "stylelint": "^9.5.0", 43 | "stylelint-config-wordpress": "^13.1.0", 44 | "webpack": "^4.25.1", 45 | "webpack-cli": "^3.1.2" 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /phpcs.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | geocities-blocks.php 16 | ./assets 17 | 18 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * External dependencies 3 | */ 4 | const path = require( 'path' ); 5 | const glob = require( 'glob' ); 6 | const CleanWebpackPlugin = require( 'clean-webpack-plugin' ); 7 | const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' ); 8 | const NODE_ENV = process.env.NODE_ENV || 'development'; 9 | 10 | const externals = { 11 | '@wordpress/api-fetch': { this: [ 'wp', 'apiFetch' ] }, 12 | '@wordpress/blocks': { this: [ 'wp', 'blocks' ] }, 13 | '@wordpress/components': { this: [ 'wp', 'components' ] }, 14 | '@wordpress/compose': { this: [ 'wp', 'compose' ] }, 15 | '@wordpress/editor': { this: [ 'wp', 'editor' ] }, 16 | '@wordpress/element': { this: [ 'wp', 'element' ] }, 17 | '@wordpress/i18n': { this: [ 'wp', 'i18n' ] }, 18 | }; 19 | 20 | /** 21 | * Automatically build any top-level files in the `js` directory. 22 | */ 23 | const entryPoints = glob.sync( './assets/js/*.js' ).reduce( ( acc, item ) => { 24 | const name = path.basename( item ).replace( '.js', '' ); 25 | acc[ name ] = item; 26 | return acc; 27 | }, {} ); 28 | 29 | /** 30 | * Config for compiling Gutenberg blocks JS. 31 | */ 32 | const GutenbergBlocksConfig = { 33 | mode: NODE_ENV, 34 | externals, 35 | entry: entryPoints, 36 | output: { 37 | path: path.resolve( __dirname, './build/' ), 38 | filename: '[name].js', 39 | libraryTarget: 'this', 40 | }, 41 | module: { 42 | rules: [ 43 | { 44 | test: /\.jsx?$/, 45 | exclude: /node_modules/, 46 | loader: 'babel-loader', 47 | }, 48 | { 49 | test: /\.s[c|a]ss$/, 50 | use: [ 51 | 'style-loader', 52 | MiniCssExtractPlugin.loader, 53 | 'css-loader', 54 | { 55 | loader: 'postcss-loader', 56 | options: { 57 | plugins: [ require( 'autoprefixer' )( { browsers: [ '>1%' ] } ) ], 58 | }, 59 | }, 60 | 'sass-loader', 61 | ], 62 | }, 63 | ], 64 | }, 65 | plugins: [ 66 | new CleanWebpackPlugin( 'build', {} ), 67 | new MiniCssExtractPlugin( { 68 | filename: '[name].css', 69 | } ), 70 | ], 71 | }; 72 | 73 | module.exports = [ GutenbergBlocksConfig ]; 74 | --------------------------------------------------------------------------------