-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plugin: Adding a build process #282
Changes from 1 commit
1640f74
6474e1d
36cadd1
1784164
13f2269
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"presets": [ | ||
[ "latest", { | ||
"es2015": { | ||
"modules": false | ||
} | ||
} ] | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"root": true, | ||
"extends": "wpcalypso", | ||
"parser": "babel-eslint", | ||
"env": { | ||
"browser": true, | ||
"node": true | ||
}, | ||
"parserOptions": { | ||
"ecmaVersion": 3 | ||
}, | ||
"rules": { | ||
"no-var": "off", | ||
"camelcase": "off" | ||
} | ||
} |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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__ ) ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Curious if |
||
wp_enqueue_script( 'gutenberg_js', plugins_url( 'build/app.js', __FILE__ ) ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This 404's because it's loading from the Gutenberg root. Should be |
||
} | ||
} | ||
add_action( 'admin_enqueue_scripts', 'gutenberg_scripts_and_styles' ); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"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", | ||
"prototype" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a prototype 😄 |
||
], | ||
"scripts": { | ||
"build": "cross-env NODE_ENV=production webpack", | ||
"clean": "rimraf build" | ||
}, | ||
"devDependencies": { | ||
"autoprefixer": "^6.7.7", | ||
"babel-core": "^6.24.0", | ||
"babel-eslint": "^7.1.1", | ||
"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-wpcalypso": "^0.6.0", | ||
"eslint-plugin-wpcalypso": "^3.0.2", | ||
"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" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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%; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import 'assets/stylesheets/main.scss'; | ||
|
||
console.log( 'Welcome to gutenberg' ); // eslint-disable-line no-console |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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%; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
|
||
const webpack = require( 'webpack' ); | ||
|
||
const config = module.exports = { | ||
entry: { | ||
app: './src/index.js' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking we should call this folder There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about the distinction There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I may put the build in the root of the plugin. |
||
}, | ||
output: { | ||
filename: 'build/[name].js', | ||
path: __dirname | ||
}, | ||
resolve: { | ||
modules: [ | ||
'src', | ||
'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'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likely ignored with
babel-eslint
parser override. Do we need to usebabel-eslint
or is the default parser sufficient?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the docs:
We may need it, if we decide to add object-spread, but we could drop it for now.