Skip to content

Commit

Permalink
Move blockified code to the module instead
Browse files Browse the repository at this point in the history
  • Loading branch information
ingeniumed committed Jun 21, 2024
1 parent eb0369c commit d1bfb1b
Show file tree
Hide file tree
Showing 11 changed files with 99 additions and 179 deletions.
61 changes: 0 additions & 61 deletions blocks/BLOCKS.md

This file was deleted.

2 changes: 0 additions & 2 deletions blocks/src/blocks.js

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 2 additions & 15 deletions modules/custom-status/custom-status.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,19 +295,6 @@ function action_admin_enqueue_scripts() {
return;
}

// // Load block editor assets and return early.
// if ( $this->is_block_editor() ) {
// global $post;

// wp_enqueue_style( 'edit-flow-block-custom-status-styles', EDIT_FLOW_URL . 'blocks/dist/custom-status.editor.build.css', false, EDIT_FLOW_VERSION );
// wp_enqueue_script( 'edit-flow-block-custom-status-script', EDIT_FLOW_URL . 'blocks/dist/custom-status.build.js', array( 'wp-blocks', 'wp-element', 'wp-edit-post', 'wp-plugins', 'wp-components' ), EDIT_FLOW_VERSION );

// $custom_statuses = apply_filters( 'ef_custom_status_list', $this->get_custom_statuses(), $post );

// wp_localize_script( 'edit-flow-block-custom-status-script', 'EditFlowCustomStatuses', array_values( $custom_statuses ) );
// return;
// }

// Load Javascript we need to use on the configuration views (jQuery Sortable and Quick Edit)
if ( $this->is_whitelisted_settings_view( $this->module->name ) ) {
wp_enqueue_script( 'jquery-ui-sortable' );
Expand Down Expand Up @@ -337,7 +324,7 @@ function load_scripts_for_block_editor(){

global $post;

wp_enqueue_script( 'edit-flow-block-custom-status-script', EDIT_FLOW_URL . 'blocks/dist/custom-status.build.js', array( 'wp-blocks', 'wp-element', 'wp-edit-post', 'wp-plugins', 'wp-components' ), EDIT_FLOW_VERSION );
wp_enqueue_script( 'edit-flow-block-custom-status-script', EDIT_FLOW_URL . 'dist/custom-status.build.js', array( 'wp-blocks', 'wp-element', 'wp-edit-post', 'wp-plugins', 'wp-components' ), EDIT_FLOW_VERSION );

$custom_statuses = apply_filters( 'ef_custom_status_list', $this->get_custom_statuses(), $post );

Expand All @@ -349,7 +336,7 @@ function load_styles_for_block_editor(){
return;
}

wp_enqueue_style( 'edit-flow-block-custom-status-styles', EDIT_FLOW_URL . 'blocks/dist/custom-status.editor.build.css', false, EDIT_FLOW_VERSION );
wp_enqueue_style( 'edit-flow-block-custom-status-styles', EDIT_FLOW_URL . 'dist/custom-status.editor.build.css', false, EDIT_FLOW_VERSION );
}

/**
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"build": "webpack --mode production",
"dev": "webpack --watch",
"wp-env": "wp-env",
"lint-js": "eslint --quiet blocks modules",
"lint-js": "eslint --quiet modules",
"test": "echo \"Error: no test specified\" && exit 1",
"test-jest": "jest -c jest.config.js",
"test-e2e": "wp-scripts test-e2e --config tests/e2e/jest.config.js",
Expand Down
196 changes: 96 additions & 100 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,110 +1,106 @@
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
var MiniCssExtractPlugin = require( 'mini-css-extract-plugin' );
var debug = process.env.NODE_ENV !== 'production';
var glob = require("glob");
var glob = require( 'glob' );

const entries = glob.sync("./blocks/src/**/block.js").reduce((acc, item) => {
const name = item.replace( /blocks\/src\/(.*)\/block.js/, '$1' )
acc[ name ] = item;
return acc;
}, {});
const entries = glob.sync( './modules/**/lib/*-block.js' ).reduce( ( acc, item ) => {
const name = item.replace( /modules\/(.*)\/lib\/(.*)-block.js/, '$1' );
acc[ name ] = item;
return acc;
}, {} );

// @todo
var extractEditorSCSS = new MiniCssExtractPlugin({
filename: './[name].editor.build.css'
});
var extractEditorSCSS = new MiniCssExtractPlugin( {
filename: './[name].editor.build.css',
} );

var extractBlockSCSS = new MiniCssExtractPlugin({
filename: './[name].style.build.css'
});
var extractBlockSCSS = new MiniCssExtractPlugin( {
filename: './[name].style.build.css',
} );

var plugins = [extractEditorSCSS, extractBlockSCSS];
var plugins = [ extractEditorSCSS, extractBlockSCSS ];

var scssConfig = [
'css-loader',
'sass-loader',
];
var scssConfig = [ 'css-loader', 'sass-loader' ];

module.exports = [
{
context: __dirname,
devtool: debug ? 'source-map' : null,
mode: debug ? 'development' : 'production',
// entry: './blocks/src/blocks.js',
entry: entries,
output: {
path: __dirname + '/blocks/dist/',
filename: "[name].build.js"
},
externals: {
'react': 'React',
'react-dom': 'ReactDOM'
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader'
}
]
},
{
test: /editor\.scss$/,
exclude: /node_modules/,
// use: extractEditorSCSS.extract(scssConfig)
use: [ MiniCssExtractPlugin.loader, ...scssConfig ],
},
{
test: /style\.scss$/,
exclude: /node_modules/,
// use: extractBlockSCSS.extract(scssConfig)
use: [ MiniCssExtractPlugin.loader, ...scssConfig ],
}
]
},
plugins: plugins
},
{
context: __dirname,
devtool: debug ? 'source-map' : null,
mode: debug ? 'development' : 'production',
entry: {
'calendar.react': __dirname + '/modules/calendar/lib/react/calendar.react.js',
},
output: {
path: __dirname + '/modules/calendar/lib/dist',
filename: "[name].build.js"
},
externals: {
'react': 'React',
'react-dom': 'ReactDOM',
'moment': 'moment',
'@wordpress/i18n': 'wp.i18n',
'@wordpress/components': 'wp.components',
'@wordpress/url': 'wp.url',
'@wordpress/data': 'wp.data'
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader'
}
]
},
{
test: /style\.react\.scss$/,
exclude: /node_modules/,
// use: extractBlockSCSS.extract(scssConfig)
use: [ MiniCssExtractPlugin.loader, ...scssConfig ],
},
]
},
plugins: plugins
}
{
context: __dirname,
devtool: debug ? 'source-map' : null,
mode: debug ? 'development' : 'production',
entry: entries,
output: {
path: __dirname + '/dist/',
filename: '[name].build.js',
},
externals: {
react: 'React',
'react-dom': 'ReactDOM',
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
},
],
},
{
test: /editor\.scss$/,
exclude: /node_modules/,
// use: extractEditorSCSS.extract(scssConfig)
use: [ MiniCssExtractPlugin.loader, ...scssConfig ],
},
{
test: /style\.scss$/,
exclude: /node_modules/,
// use: extractBlockSCSS.extract(scssConfig)
use: [ MiniCssExtractPlugin.loader, ...scssConfig ],
},
],
},
plugins,
},
{
context: __dirname,
devtool: debug ? 'source-map' : null,
mode: debug ? 'development' : 'production',
entry: {
'calendar.react': __dirname + '/modules/calendar/lib/react/calendar.react.js',
},
output: {
path: __dirname + '/modules/calendar/lib/dist',
filename: '[name].build.js',
},
externals: {
react: 'React',
'react-dom': 'ReactDOM',
moment: 'moment',
'@wordpress/i18n': 'wp.i18n',
'@wordpress/components': 'wp.components',
'@wordpress/url': 'wp.url',
'@wordpress/data': 'wp.data',
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
},
],
},
{
test: /style\.react\.scss$/,
exclude: /node_modules/,
// use: extractBlockSCSS.extract(scssConfig)
use: [ MiniCssExtractPlugin.loader, ...scssConfig ],
},
],
},
plugins,
},
];

0 comments on commit d1bfb1b

Please sign in to comment.