luangjokaj / wordpressify

🎈 Automate your WordPress development workflow.
http://www.wordpressify.co
MIT License
1.6k stars 142 forks source link

Question: how to add the js generated by @wordpress/scripts to the wordpressify workflow? #55

Closed nasatome closed 4 years ago

nasatome commented 4 years ago

Hello, I'm new to the world of Wordpress, and I'm a beginner so I don't know the best practices.

I'm currently developing a theme, and I'm adding some gutenberg plugins to it, I use the following commands:

npm install @wordpress/scripts --save-dev
npm start 

this generates me a index.js file inside a build folder that I added by means of

wp_register_script('custom-blocks', get_template_directory_uri().'/build/index.js',array('wp-blocks','wp-editor','wp-data'),microtime(),true);

is there any way to generate and import this file without continually compiling that file? (or should I add it to the gulp process?) or could it be imported directly my jsx type files? by placing it in the assess/js/index.js folder ?

//index.js
import './blocks/quote';
//blocks/quote.js
const {registerBlockType} = wp.blocks;
const {InnerBlocks, RichText} = wp.editor;
registerBlockType("ak/quote", {
  title: "Custom Block",
  description: "this is a description",
  icon: "smiley",
  category: "layout",
  //custom attributes
  attributes: {
    title: {
      type: "string",
      source: "html",
      selector: "h2"
    },
    body: {
      type: "string",
      source: "html",
      selector: "p"
    }
  },
  edit ({attributes, setAttributes}) {
  ...
luangjokaj commented 4 years ago

Sorry we don't provide support here.