Skip to content
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

[AMP Stories] JS Build Tooling Optimizations #2000

Merged
merged 23 commits into from
Mar 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8acd284
Begin integrating `@wordpress/scripts` package
swissspidy Mar 19, 2019
f998387
Update webpack config to re-use parts from upstream
swissspidy Mar 19, 2019
1ba6540
Remove Webpack part from Gruntfile
swissspidy Mar 19, 2019
1951d1e
Stylelint: allow AMP custom elements
swissspidy Mar 19, 2019
25622f6
Use require.context for block registration
swissspidy Mar 20, 2019
33c58aa
Update scripts / webpack config
swissspidy Mar 20, 2019
0737b95
Merge branch 'amp-stories-redux' into amp-story/use-wordpress-scripts
swissspidy Mar 20, 2019
650e585
EditorCarousel: return early if element wasn’t found
swissspidy Mar 20, 2019
bf0cb6d
DRY PreviewPicker component
swissspidy Mar 20, 2019
3dca773
Add missing css-loader
swissspidy Mar 20, 2019
4fcd91b
Fix amp-stories JS URL
swissspidy Mar 20, 2019
a199b60
Ignore source maps
swissspidy Mar 20, 2019
52b563a
Fix regex for story blocks require.context
swissspidy Mar 20, 2019
c017087
Add suffix to compiled CSS files
swissspidy Mar 20, 2019
23d51c8
Fix regex for non-story blocks require.context
swissspidy Mar 20, 2019
716d0cd
Add lint fix scripts
swissspidy Mar 20, 2019
591158a
Merge branch 'amp-stories-redux' into amp-story/use-wordpress-scripts
swissspidy Mar 20, 2019
9664be3
Merge branch 'amp-stories-redux' into amp-story/use-wordpress-scripts
swissspidy Mar 21, 2019
e098b0e
run `npm audit fix`
swissspidy Mar 25, 2019
ce74c5e
Register blocks after filters have been applied
swissspidy Mar 25, 2019
5f81348
Add some initial PostCSS config with RTLCSS support
swissspidy Mar 26, 2019
0e8185a
Merge branch 'amp-stories-redux' into amp-story/use-wordpress-scripts
swissspidy Mar 28, 2019
028e03d
Merge branch 'amp-stories-redux' into amp-story/use-wordpress-scripts
swissspidy Mar 28, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extends @wordpress/browserslist-config
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
node_modules
wiki
amp.zip
assets/css/*-compiled.css
assets/css/*-compiled-rtl.css
assets/css/*.map
assets/js/*-compiled.js
assets/js/*.map
built
/amphtml
6 changes: 6 additions & 0 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "stylelint-config-wordpress",
"rules": {
"selector-type-no-unknown": [ true, { "ignore": ["custom-elements"] } ]
}
}
2 changes: 0 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ module.exports = function( grunt ) {
// Clear out all existing compiled files first.
grunt.task.run( 'clean' );

grunt.task.run( 'shell:webpack_production' );

spawnQueue.push(
{
cmd: 'git',
Expand Down
11 changes: 11 additions & 0 deletions assets/src/amp-blocks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* WordPress dependencies
*/
import { registerBlockType } from '@wordpress/blocks';

const context = require.context( './blocks', true, /((?<!story.*)\/index\.js)$/ );

context.keys().forEach( ( modulePath ) => {
const { name, settings } = context( modulePath );
registerBlockType( name, settings );
} );
17 changes: 16 additions & 1 deletion assets/src/amp-story-editor-blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ import { every } from 'lodash';
import { addFilter } from '@wordpress/hooks';
import domReady from '@wordpress/dom-ready';
import { select, subscribe, dispatch } from '@wordpress/data';
import { createBlock, getDefaultBlockName, setDefaultBlockName, getBlockTypes, unregisterBlockType } from '@wordpress/blocks';
import {
createBlock,
getDefaultBlockName,
setDefaultBlockName,
getBlockTypes,
unregisterBlockType,
registerBlockType,
} from '@wordpress/blocks';

/**
* Internal dependencies
Expand Down Expand Up @@ -332,3 +339,11 @@ addFilter( 'editor.BlockListBlock', 'ampStoryEditorBlocks/withActivePageState',
addFilter( 'editor.BlockListBlock', 'ampStoryEditorBlocks/addWrapperProps', withWrapperProps );
addFilter( 'blocks.getSaveContent.extraProps', 'ampStoryEditorBlocks/addExtraAttributes', addAMPExtraProps );
addFilter( 'editor.BlockDropZone', 'ampStoryEditorBlocks/withStoryBlockDropZone', withStoryBlockDropZone );

const context = require.context( './blocks', true, /\/.*-story.*\/index\.js$/ );

// Block types need to be register *after* all the filters have been applied.
context.keys().forEach( ( modulePath ) => {
const { name, settings } = context( modulePath );
registerBlockType( name, settings );
} );
Loading