diff --git a/.gitignore b/.gitignore index 3c3629e647f5d..a9f2f097d1b1e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +plugin/build diff --git a/plugin/.babelrc b/plugin/.babelrc new file mode 100644 index 0000000000000..a297ca0ee703e --- /dev/null +++ b/plugin/.babelrc @@ -0,0 +1,9 @@ +{ + "presets": [ + [ "latest", { + "es2015": { + "modules": false + } + } ] + ] +} diff --git a/plugin/.editorconfig b/plugin/.editorconfig new file mode 100644 index 0000000000000..667a507d56e97 --- /dev/null +++ b/plugin/.editorconfig @@ -0,0 +1,16 @@ +# http://editorconfig.org +root = true + +[*] +indent_style = tab +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[package.json] +indent_style = space +indent_size = 2 + +[*.md] +trim_trailing_whitespace = false diff --git a/plugin/.eslintrc.json b/plugin/.eslintrc.json new file mode 100644 index 0000000000000..ad2eb915a6758 --- /dev/null +++ b/plugin/.eslintrc.json @@ -0,0 +1,55 @@ +{ + "root": true, + "extends": "wordpress", + "env": { + "browser": true + }, + "parserOptions": { + "sourceType": "module" + }, + "rules": { + "array-bracket-spacing": [ "error", "always" ], + "brace-style": [ "error", "1tbs" ], + "comma-spacing": "error", + "comma-style": "error", + "computed-property-spacing": [ "error", "always" ], + "dot-notation": "error", + "eol-last": "error", + "func-call-spacing": "error", + "indent": [ "error", "tab", { "SwitchCase": 1 } ], + "key-spacing": "error", + "keyword-spacing": "error", + "no-console": "error", + "no-debugger": "error", + "no-dupe-args": "error", + "no-dupe-keys": "error", + "no-duplicate-case": "error", + "no-else-return": "error", + "no-extra-semi": "error", + "no-lonely-if": "error", + "no-mixed-spaces-and-tabs": "error", + "no-multiple-empty-lines": [ "error", { "max": 1 } ], + "no-multi-spaces": "error", + "no-negated-in-lhs": "error", + "no-nested-ternary": "error", + "no-redeclare": "error", + "no-shadow": "error", + "no-unreachable": "error", + "no-use-before-define": [ "error", "nofunc" ], + "object-curly-spacing": [ "error", "always" ], + "padded-blocks": [ "error", "never" ], + "quote-props": [ "error", "as-needed", { "keywords": true } ], + "semi": "error", + "semi-spacing": "error", + "space-before-blocks": [ "error", "always" ], + "space-before-function-paren": [ "error", "never" ], + "space-in-parens": [ "error", "always" ], + "space-infix-ops": [ "error", { "int32Hint": false } ], + "space-unary-ops": [ "error", { + "overrides": { + "!": true + } + } ], + "valid-jsdoc": [ "error", { "requireReturn": false } ] + } +} diff --git a/plugin/editor/assets/stylesheets/main.scss b/plugin/editor/assets/stylesheets/main.scss new file mode 100644 index 0000000000000..f5ec492c04797 --- /dev/null +++ b/plugin/editor/assets/stylesheets/main.scss @@ -0,0 +1,13 @@ +.gutenberg { + background: #fff; + margin: -20px 0 0 -20px; + padding: 60px; +} + +.gutenberg__editor { + max-width: 700px; + margin: 0 auto; + img { + max-width: 100%; + } +} diff --git a/plugin/editor/index.js b/plugin/editor/index.js new file mode 100644 index 0000000000000..ad4922d3556c6 --- /dev/null +++ b/plugin/editor/index.js @@ -0,0 +1,3 @@ +import 'assets/stylesheets/main.scss'; + +console.log( 'Welcome to gutenberg' ); // eslint-disable-line no-console diff --git a/plugin/index.php b/plugin/index.php index 75b54156eafa4..16951e28c2d02 100644 --- a/plugin/index.php +++ b/plugin/index.php @@ -21,7 +21,7 @@ function gutenberg_menu() { function gutenberg_scripts_and_styles( $hook ) { if ( $hook === 'toplevel_page_gutenberg' ) { - wp_enqueue_style( 'gutenberg_css', plugins_url( 'style.css', __FILE__ ) ); + wp_enqueue_script( 'gutenberg_js', plugins_url( 'build/app.js', __FILE__ ) ); } } add_action( 'admin_enqueue_scripts', 'gutenberg_scripts_and_styles' ); diff --git a/plugin/package.json b/plugin/package.json new file mode 100644 index 0000000000000..50099be75d9dd --- /dev/null +++ b/plugin/package.json @@ -0,0 +1,33 @@ +{ + "name": "gutenberg", + "version": "1.0.0", + "description": "Prototyping a new WordPress editor experience", + "main": "build/app.js", + "repository": "git+https://github.com/WordPress/gutenberg.git", + "author": "The WordPress Contributors", + "license": "GPL-2.0+", + "keywords": [ + "WordPress", + "editor" + ], + "scripts": { + "build": "cross-env NODE_ENV=production webpack", + "clean": "rimraf build" + }, + "devDependencies": { + "autoprefixer": "^6.7.7", + "babel-core": "^6.24.0", + "babel-loader": "^6.4.1", + "babel-preset-latest": "^6.24.0", + "cross-env": "^3.2.4", + "css-loader": "^0.27.3", + "eslint": "^3.17.1", + "eslint-config-wordpress": "^1.1.0", + "node-sass": "^4.5.0", + "postcss-loader": "^1.3.3", + "rimraf": "^2.6.1", + "sass-loader": "^6.0.3", + "style-loader": "^0.14.1", + "webpack": "^2.2.1" + } +} diff --git a/plugin/style.css b/plugin/style.css index 6a0d89125092b..8b137891791fe 100644 --- a/plugin/style.css +++ b/plugin/style.css @@ -1,14 +1 @@ -.gutenberg { - background: #fff; - margin: -20px 0 0 -20px; - padding: 60px; -} -.gutenberg__editor { - max-width: 700px; - margin: 0 auto; -} - -.gutenberg__editor img { - max-width: 100%; -} diff --git a/plugin/webpack.config.js b/plugin/webpack.config.js new file mode 100644 index 0000000000000..77cb341a05585 --- /dev/null +++ b/plugin/webpack.config.js @@ -0,0 +1,55 @@ +/** + * External dependencies + */ + +const webpack = require( 'webpack' ); + +const config = module.exports = { + entry: { + app: './editor/index.js' + }, + output: { + filename: 'build/[name].js', + path: __dirname + }, + resolve: { + modules: [ + 'editor', + 'node_modules' + ] + }, + module: { + rules: [ + { + test: /\.js$/, + use: 'babel-loader' + }, + { + test: /\.s?css$/, + use: [ + { loader: 'style-loader' }, + { loader: 'css-loader' }, + { loader: 'postcss-loader' }, + { loader: 'sass-loader' } + ] + } + ] + }, + plugins: [ + new webpack.LoaderOptionsPlugin( { + minimize: process.env.NODE_ENV === 'production', + debug: process.env.NODE_ENV !== 'production', + options: { + postcss: [ + require( 'autoprefixer' ) + ] + } + } ) + ] +}; + +if ( 'production' === process.env.NODE_ENV ) { + config.plugins.push( new webpack.optimize.UglifyJsPlugin() ); +} else { + config.devtool = 'source-map'; +}