Get With Gutenberg - Getting Started with Block Development in ES.Next • https://getwithgutenberg.com/2019/03/getting-started-with-block-development-in-es-next/
> 1% | |
ie >= 11 | |
last 1 Android versions | |
last 1 ChromeAndroid versions | |
last 2 Chrome versions | |
last 2 Firefox versions | |
last 2 Safari versions | |
last 2 iOS versions | |
last 2 Edge versions | |
last 2 Opera versions |
const externals = { | |
wp: 'wp', | |
react: 'React', | |
'react-dom': 'ReactDOM', | |
}; | |
const isProduction = process.env.NODE_ENV === 'production'; | |
const mode = isProduction ? 'production' : 'development'; | |
module.exports = { | |
mode, | |
entry: './block.js', | |
output: { | |
path: __dirname, | |
filename: 'block.build.js', | |
}, | |
externals, | |
module: { | |
rules: [ | |
{ | |
test: /\.js$/, | |
exclude: /node_modules/, | |
use: { | |
loader: 'babel-loader', | |
}, | |
}, | |
], | |
}, | |
}; |
<?php | |
function gwg_editor_assets() { | |
wp_enqueue_script( | |
'gwg-block-js', | |
plugin_dir_url( __FILE__ ) . 'block.build.js', | |
[], | |
false, | |
true // Enqueue script in the footer. | |
); | |
wp_enqueue_style( | |
'gwg-editor-css', | |
plugin_dir_url( __FILE__ ) . 'editor.css', | |
); | |
} | |
add_action( 'enqueue_block_editor_assets', 'gwg_editor_assets' ); |
{ | |
"presets": [ "@babel/preset-env", "@babel/preset-react" ] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment