From d3e784d2916cf5dc17975205e5a7939b8f51b13c Mon Sep 17 00:00:00 2001 From: Sofia Sousa Date: Wed, 7 Nov 2018 13:26:49 +0000 Subject: [PATCH] feat: Update package versions and order they should be imported feat: Change expose style config --- package.json | 35 ++++++----- src/js/index.js | 121 +++++++++++++++++++----------------- src/scss/block-library.scss | 10 +++ src/scss/style.scss | 9 ++- webpack.config.js | 45 +++++--------- 5 files changed, 117 insertions(+), 103 deletions(-) create mode 100644 src/scss/block-library.scss diff --git a/package.json b/package.json index 70db9a0..c923264 100644 --- a/package.json +++ b/package.json @@ -33,42 +33,44 @@ ], "dependencies": { "@wordpress/a11y": "^2.0.2", - "@wordpress/api-fetch": "^2.2.1", + "@wordpress/api-fetch": "2.2.2", "@wordpress/autop": "^2.0.2", "@wordpress/blob": "^2.1.0", - "@wordpress/block-library": "^2.1.7", - "@wordpress/block-serialization-default-parser": "^1.0.1", - "@wordpress/blocks": "^5.1.1", - "@wordpress/components": "^5.0.1", - "@wordpress/core-data": "^2.0.8", - "@wordpress/data": "^3.0.1", + "@wordpress/block-library": "2.1.8", + "@wordpress/block-serialization-default-parser": "^1.0.2", + "@wordpress/blocks": "5.1.2", + "@wordpress/components": "^5.0.2", + "@wordpress/core-data": "^2.0.9", + "@wordpress/data": "^3.1.0", "@wordpress/date": "^2.1.0", "@wordpress/deprecated": "^2.0.3", "@wordpress/dom": "^2.0.4", "@wordpress/dom-ready": "^2.0.2", - "@wordpress/edit-post": "^2.0.2", - "@wordpress/editor": "^6.1.0", + "@wordpress/edit-post": "2.0.3", + "@wordpress/editor": "6.1.1", "@wordpress/element": "^2.1.5", "@wordpress/escape-html": "^1.0.1", + "@wordpress/format-library": "^1.0.3", "@wordpress/hooks": "^2.0.3", "@wordpress/html-entities": "^2.0.2", "@wordpress/i18n": "^3.0.1", "@wordpress/is-shallow-equal": "^1.1.4", "@wordpress/keycodes": "^2.0.3", - "@wordpress/nux": "^2.0.8", + "@wordpress/notices": "^1.0.2", + "@wordpress/nux": "^2.0.9", "@wordpress/plugins": "^2.0.6", "@wordpress/redux-routine": "^3.0.3", - "@wordpress/rich-text": "^2.0.1", + "@wordpress/rich-text": "^2.0.2", "@wordpress/shortcode": "^2.0.2", "@wordpress/token-list": "^1.0.2", - "@wordpress/url": "^2.2.0", - "@wordpress/viewport": "^2.0.7", + "@wordpress/url": "~2.2.0", + "@wordpress/viewport": "^2.0.8", "@wordpress/wordcount": "^2.0.3", "tinymce": "4.8.0" }, "devDependencies": { - "@wordpress/babel-plugin-makepot": "^1.0.1", - "@wordpress/scripts": "^1.2.0", + "@wordpress/babel-plugin-makepot": "^2.1.2", + "@wordpress/scripts": "^2.4.1", "babel-core": "^6.26.3", "babel-eslint": "7.2.3", "babel-jest": "20.0.3", @@ -84,13 +86,12 @@ "extract-text-webpack-plugin": "4.0.0-beta.0", "node-sass": "git://github.com/sass/node-sass.git#v4.7.0", "path-replace-loader": "^2.0.0", - "pegjs": "0.10.0", "postcss-color-function": "4.0.1", "postcss-loader": "2.1.3", "postcss-wrapper-loader": "0.0.2", - "string-replace-webpack-plugin": "^0.1.3", "raw-loader": "0.5.1", "sass-loader": "6.0.7", + "string-replace-webpack-plugin": "^0.1.3", "webpack": "4.8.3", "webpack-cli": "2.1.3" }, diff --git a/src/js/index.js b/src/js/index.js index 81638d4..5116242 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -6,30 +6,34 @@ import './init'; /** * WordPress dependencies */ +import * as hooks from '@wordpress/hooks'; +import domReady from '@wordpress/dom-ready'; +import * as a11y from '@wordpress/a11y'; +import * as i18n from '@wordpress/i18n'; +// wp.i18n.setLocaleData + +import * as url from '@wordpress/url'; +import apiFetch from '@wordpress/api-fetch'; +import './scripts/api-fetch.js'; + import * as autop from '@wordpress/autop'; import * as blob from '@wordpress/blob'; import * as blockSerializationDefaultParser from '@wordpress/block-serialization-default-parser'; +import deprecated from '@wordpress/deprecated'; import * as escapeHtml from '@wordpress/escape-html'; import * as element from '@wordpress/element'; import * as isShallowEqual from '@wordpress/is-shallow-equal'; import * as compose from '@wordpress/compose'; -import * as hooks from '@wordpress/hooks'; -import deprecated from '@wordpress/deprecated'; import * as reduxRoutine from '@wordpress/redux-routine'; import * as data from '@wordpress/data'; import './scripts/data.js'; import * as dom from '@wordpress/dom'; -import * as i18n from '@wordpress/i18n'; import * as shortcode from '@wordpress/shortcode'; import * as blocks from '@wordpress/blocks'; -import domReady from '@wordpress/dom-ready'; -import * as a11y from '@wordpress/a11y'; - -import * as url from '@wordpress/url'; -import apiFetch from '@wordpress/api-fetch'; -import './scripts/api-fetch.js'; +// wp.blocks.setCategories +// wp.blocks.unstable__bootstrapServerSideBlockDefinitions import * as htmlEntities from '@wordpress/html-entities'; import * as keycodes from '@wordpress/keycodes'; @@ -37,99 +41,102 @@ import * as richText from '@wordpress/rich-text'; import * as components from '@wordpress/components'; import * as coreData from '@wordpress/core-data'; import * as date from '@wordpress/date'; +// wp.date.setSettings + +import * as notices from '@wordpress/notices'; import * as nux from '@wordpress/nux'; import * as tokenList from '@wordpress/token-list'; import * as viewport from '@wordpress/viewport'; import * as wordcount from '@wordpress/wordcount'; +// _wpMetaBoxUrl import { editor, oldEditor } from './scripts/editor.js'; +// window._wpGutenbergCodeEditorSettings import * as plugins from '@wordpress/plugins'; import * as blockLibrary from '@wordpress/block-library'; import * as editPost from '@wordpress/edit-post'; +import * as formatLibrary from '@wordpress/format-library'; // Style -import '@wordpress/components/build-style/style.css'; -import '@wordpress/nux/build-style/style.css'; -import '@wordpress/editor/build-style/style.css'; -import '@wordpress/block-library/build-style/theme.css'; -import '@wordpress/block-library/build-style/editor.css'; -import '@wordpress/edit-post/build-style/style.css'; +import '../scss/block-library.scss'; import '../scss/style.scss'; // Set global wp window.wp = { + a11y, apiFetch, - url, - autop, blob, + blockLibrary, blockSerializationDefaultParser, - escapeHtml, - element, - isShallowEqual, + blocks, + components, compose, - hooks, - deprecated, - reduxRoutine, + coreData, data, + date, + deprecated, dom, - i18n, - shortcode, - blocks, domReady, - a11y, + editPost, + editor, + element, + escapeHtml, + formatLibrary, + hooks, htmlEntities, + i18n, + isShallowEqual, keycodes, - richText, - components, - coreData, - date, + notices, nux, + oldEditor, + plugins, + reduxRoutine, + richText, + shortcode, tokenList, + url, viewport, wordcount, - editor, - oldEditor, - plugins, - blockLibrary, - editPost, }; export { + a11y, apiFetch, - url, - autop, blob, + blockLibrary, blockSerializationDefaultParser, - escapeHtml, - element, - isShallowEqual, + blocks, + components, compose, - hooks, - deprecated, - reduxRoutine, + coreData, data, + date, + deprecated, dom, - i18n, - shortcode, - blocks, domReady, - a11y, + editPost, + editor, + element, + escapeHtml, + formatLibrary, + hooks, htmlEntities, + i18n, + isShallowEqual, keycodes, - richText, - components, - coreData, - date, + notices, nux, + oldEditor, + plugins, + reduxRoutine, + richText, + shortcode, tokenList, + url, viewport, wordcount, - editor, - oldEditor, - plugins, - blockLibrary, - editPost, }; diff --git a/src/scss/block-library.scss b/src/scss/block-library.scss new file mode 100644 index 0000000..8773234 --- /dev/null +++ b/src/scss/block-library.scss @@ -0,0 +1,10 @@ +@import '~@wordpress/block-library/build-style/style.css'; + +/* + * TEMPORARY FIXES + */ + +// gutenberg/packages/block-library/src/media-text/style.scss +.wp-block-media-text.has-media-on-the-right { + grid-template-areas: "media-text-content media-text-media"; +} diff --git a/src/scss/style.scss b/src/scss/style.scss index ee043e7..cd7ad0c 100644 --- a/src/scss/style.scss +++ b/src/scss/style.scss @@ -1,4 +1,11 @@ -// @import 'gbcolors'; +@import '~@wordpress/format-library/build-style/style.css'; +@import '~@wordpress/components/build-style/style.css'; +@import '~@wordpress/nux/build-style/style.css'; +@import '~@wordpress/editor/build-style/style.css'; +@import '~@wordpress/block-library/build-style/theme.css'; +@import '~@wordpress/block-library/build-style/editor.css'; +@import '~@wordpress/edit-post/build-style/style.css'; + @import 'media-library'; @media (min-width: 600px) { diff --git a/webpack.config.js b/webpack.config.js index c64ea55..52c8105 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,14 +2,12 @@ * External dependencies */ const ExtractTextPlugin = require('extract-text-webpack-plugin'); -const CopyWebpackPlugin = require('copy-webpack-plugin'); -const postcss = require('postcss'); const { resolve } = require('path'); -/** - * Gutenberg-js dependencies - */ +const extractCSS = new ExtractTextPlugin('./css/style.css'); +const extractBLCSS = new ExtractTextPlugin('./css/block-library/style.css'); + // const PostCssWrapper = require('postcss-wrapper-loader'); // const StringReplacePlugin = require('string-replace-webpack-plugin'); const CleanWebpackPlugin = require('clean-webpack-plugin'); @@ -65,7 +63,6 @@ module.exports = { modules: [ __dirname, resolve(__dirname, 'node_modules'), - // resolve(__dirname, 'node_modules/gutenberg/node_modules'), ], alias, }, @@ -117,8 +114,18 @@ module.exports = { }), },*/ { - test: /\.s?css$/, - use: ExtractTextPlugin.extract({ + test: /style\.s?css$/, + use: extractCSS.extract({ + fallback: 'style-loader', // creates style nodes from JS strings + use: [ + { loader: 'css-loader' }, // translates CSS into CommonJS + { loader: 'sass-loader' }, // compiles Sass to CSS + ], + }), + }, + { + test: /block-library\.s?css$/, + use: extractBLCSS.extract({ fallback: 'style-loader', // creates style nodes from JS strings use: [ { loader: 'css-loader' }, // translates CSS into CommonJS @@ -129,30 +136,12 @@ module.exports = { ], }, plugins: [ - new ExtractTextPlugin('./css/style.css'), + extractCSS, + extractBLCSS, // wrapping editor style with .gutenberg__editor class // new PostCssWrapper('./css/block-library/edit-blocks.css', '.gutenberg__editor'), // new StringReplacePlugin(), new CleanWebpackPlugin(['build']), - new CopyWebpackPlugin([ - { - from: `./node_modules/@wordpress/block-library/build-style/style.css`, - to: `./css/block-library/`, - flatten: true, - transform: content => { - if (process.env.NODE_ENV === 'production') { - return postcss([ - require('cssnano')({ - preset: 'default', - }), - ]) - .process(content, { from: 'src/app.css', to: 'dest/app.css' }) - .then(result => result.css); - } - return content; - }, - }, - ]), ], stats: { children: false,