diff --git a/.eslintignore b/.eslintignore index 1f6015f87718e..ba2bd1dddf6cf 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1 +1,2 @@ -modules/*/build +build +docs diff --git a/modules/blocks/components/editable/index.js b/blocks/components/editable/index.js similarity index 100% rename from modules/blocks/components/editable/index.js rename to blocks/components/editable/index.js diff --git a/modules/blocks/index.js b/blocks/index.js similarity index 100% rename from modules/blocks/index.js rename to blocks/index.js diff --git a/modules/blocks/parser/index.js b/blocks/parser/index.js similarity index 100% rename from modules/blocks/parser/index.js rename to blocks/parser/index.js diff --git a/modules/blocks/parser/post.pegjs b/blocks/parser/post.pegjs similarity index 100% rename from modules/blocks/parser/post.pegjs rename to blocks/parser/post.pegjs diff --git a/modules/blocks/parser/test/index.js b/blocks/parser/test/index.js similarity index 100% rename from modules/blocks/parser/test/index.js rename to blocks/parser/test/index.js diff --git a/modules/blocks/test/index.js b/blocks/test/index.js similarity index 100% rename from modules/blocks/test/index.js rename to blocks/test/index.js diff --git a/modules/editor/assets/stylesheets/main.scss b/editor/assets/stylesheets/main.scss similarity index 100% rename from modules/editor/assets/stylesheets/main.scss rename to editor/assets/stylesheets/main.scss diff --git a/modules/editor/blocks/index.js b/editor/blocks/index.js similarity index 100% rename from modules/editor/blocks/index.js rename to editor/blocks/index.js diff --git a/modules/editor/blocks/text-block/index.js b/editor/blocks/text-block/index.js similarity index 100% rename from modules/editor/blocks/text-block/index.js rename to editor/blocks/text-block/index.js diff --git a/modules/editor/editor/editor.js b/editor/editor/editor.js similarity index 100% rename from modules/editor/editor/editor.js rename to editor/editor/editor.js diff --git a/modules/editor/editor/index.js b/editor/editor/index.js similarity index 100% rename from modules/editor/editor/index.js rename to editor/editor/index.js diff --git a/modules/editor/index.js b/editor/index.js similarity index 100% rename from modules/editor/index.js rename to editor/index.js diff --git a/modules/editor/inserter/button.js b/editor/inserter/button.js similarity index 100% rename from modules/editor/inserter/button.js rename to editor/inserter/button.js diff --git a/modules/editor/inserter/index.js b/editor/inserter/index.js similarity index 100% rename from modules/editor/inserter/index.js rename to editor/inserter/index.js diff --git a/modules/editor/inserter/style.scss b/editor/inserter/style.scss similarity index 100% rename from modules/editor/inserter/style.scss rename to editor/inserter/style.scss diff --git a/modules/element/index.js b/element/index.js similarity index 100% rename from modules/element/index.js rename to element/index.js diff --git a/index.php b/index.php index 139ba71466e6d..8e62cf3f3db0f 100644 --- a/index.php +++ b/index.php @@ -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' ); @@ -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__ ) ); } } diff --git a/package.json b/package.json index 6373bec01c37d..9f2aeeee53482 100644 --- a/package.json +++ b/package.json @@ -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 .", "dev": "webpack --watch", "test": "npm run lint && npm run test-unit" }, @@ -47,6 +47,6 @@ "webpack-node-externals": "^1.5.4" }, "dependencies": { - "hpq": "^1.1.0" + "hpq": "^1.1.1" } } diff --git a/webpack.config.js b/webpack.config.js index 7b28a9ca1f09a..481729d2554d6 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -3,36 +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'; - -/** - * Object of Webpack entry points consisting of modules discovered in the base - * path subdirectory. Treating each as an independent bundle with a shared - * configuration for library output provides a consistent authoring environment - * and exposes each separately on the global scope (window.wp.blocks, etc.). - * - * @type {Object} - */ -const entry = [ 'blocks', 'editor', 'element' ].reduce( ( memo, submodule ) => { - return Object.assign( memo, { - [ submodule ]: [ BASE_PATH, submodule, 'index.js' ].join( '/' ) - } ); -}, {} ); - const config = { - entry: entry, + entry: { + 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' }, @@ -48,10 +30,7 @@ const config = { }, { test: /\.js$/, - include: [ - __dirname + '/modules', - __dirname + '/node_modules/hpq' - ], + exclude: /node_modules/, use: 'babel-loader' }, { @@ -95,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',