Skip to content

Commit

Permalink
Flatten modules into top-level directory
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Mar 24, 2017
1 parent 3c35361 commit fa8cd1c
Show file tree
Hide file tree
Showing 20 changed files with 11 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
modules/*/build
build
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ function gutenberg_register_scripts() {
wp_register_script( 'react-dom', 'https://unpkg.com/react-dom@15/dist/react-dom' . $suffix . '.js', array( 'react' ) );

// Editor
wp_register_script( 'wp-element', plugins_url( 'modules/element/build/index.js', __FILE__ ), array( 'react', 'react-dom' ) );
wp_register_script( 'wp-blocks', plugins_url( 'modules/blocks/build/index.js', __FILE__ ), array( 'wp-element' ) );
wp_register_script( 'wp-element', plugins_url( 'element/build/index.js', __FILE__ ), array( 'react', 'react-dom' ) );
wp_register_script( 'wp-blocks', plugins_url( 'blocks/build/index.js', __FILE__ ), array( 'wp-element' ) );
}
add_action( 'init', 'gutenberg_register_scripts' );

Expand All @@ -58,11 +58,11 @@ function gutenberg_scripts_and_styles( $hook ) {
if ( 'toplevel_page_gutenberg' === $hook ) {
// Scripts
wp_register_script( 'gutenberg-content', plugins_url( 'post-content.js', __FILE__ ) );
wp_enqueue_script( 'wp-editor', plugins_url( 'modules/editor/build/index.js', __FILE__ ), array( 'wp-blocks', 'wp-element', 'gutenberg-content' ), false, true );
wp_enqueue_script( 'wp-editor', plugins_url( 'editor/build/index.js', __FILE__ ), array( 'wp-blocks', 'wp-element', 'gutenberg-content' ), false, true );
wp_add_inline_script( 'wp-editor', 'wp.editor.createEditorInstance( \'editor\', { content: window.content } );' );

// Styles
wp_enqueue_style( 'wp-editor', plugins_url( 'modules/editor/build/style.css', __FILE__ ) );
wp_enqueue_style( 'wp-editor', plugins_url( 'editor/build/style.css', __FILE__ ) );
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"scripts": {
"test-unit": "cross-env NODE_ENV=test webpack && mocha build --require bootstrap-test.js",
"build": "cross-env NODE_ENV=production webpack",
"lint": "eslint modules",
"lint": "eslint editor blocks element",
"dev": "webpack --watch",
"test": "npm run lint && npm run test-unit"
},
Expand Down
18 changes: 5 additions & 13 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,18 @@
*/

const glob = require( 'glob' );
const path = require( 'path' );
const webpack = require( 'webpack' );
const ExtractTextPlugin = require( 'extract-text-webpack-plugin' );

/**
* Base path from which modules are to be discovered.
*
* @type {String}
*/
const BASE_PATH = './modules';

const config = {
entry: {
blocks: BASE_PATH + '/blocks/index.js',
editor: BASE_PATH + '/editor/index.js',
element: BASE_PATH + '/element/index.js'
blocks: './blocks/index.js',
editor: './editor/index.js',
element: './element/index.js'
},
output: {
filename: '[name]/build/index.js',
path: path.resolve( BASE_PATH ),
path: __dirname,
library: [ 'wp', '[name]' ],
libraryTarget: 'this'
},
Expand Down Expand Up @@ -82,7 +74,7 @@ switch ( process.env.NODE_ENV ) {

case 'test':
config.target = 'node';
config.entry = glob.sync( BASE_PATH + '/**/test/*.js' );
config.entry = glob.sync( `./{${ Object.keys( config.entry ).join() }}/test/*.js` );
config.externals = [ require( 'webpack-node-externals' )() ];
config.output = {
filename: 'build/test.js',
Expand Down

0 comments on commit fa8cd1c

Please sign in to comment.