woocommerce/plugins/woocommerce-blocks/webpack.config.js

332 lines
8.3 KiB
JavaScript
Raw Normal View History

/**
* External dependencies
*/
const path = require( 'path' );
const MergeExtractFilesPlugin = require( './bin/merge-extract-files-webpack-plugin' );
const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' );
const { CleanWebpackPlugin } = require( 'clean-webpack-plugin' );
const ProgressBarPlugin = require( 'progress-bar-webpack-plugin' );
const DependencyExtractionWebpackPlugin = require( '@wordpress/dependency-extraction-webpack-plugin' );
const chalk = require( 'chalk' );
const NODE_ENV = process.env.NODE_ENV || 'development';
const WebpackRTLPlugin = require( 'webpack-rtl-plugin' );
function findModuleMatch( module, match ) {
if ( module.request && match.test( module.request ) ) {
return true;
} else if ( module.issuer ) {
return findModuleMatch( module.issuer, match );
}
return false;
}
const baseConfig = {
mode: NODE_ENV,
performance: {
hints: false,
},
stats: {
all: false,
assets: true,
builtAt: true,
colors: true,
errors: true,
hash: true,
timings: true,
},
};
const requestToExternal = ( request ) => {
const wcDepMap = {
'@woocommerce/settings': [ 'wc', 'wc-shared-settings' ],
'@woocommerce/block-settings': [ 'wc', 'wc-block-settings' ],
};
if ( wcDepMap[ request ] ) {
return wcDepMap[ request ];
}
};
const requestToHandle = ( request ) => {
const wcHandleMap = {
'@woocommerce/settings': 'wc-shared-settings',
'@woocommerce/block-settings': 'wc-block-settings',
};
if ( wcHandleMap[ request ] ) {
return wcHandleMap[ request ];
}
};
const CoreConfig = {
...baseConfig,
entry: {
'wc-shared-settings': './assets/js/settings/shared/index.js',
'wc-block-settings': './assets/js/settings/blocks/index.js',
},
output: {
filename: '[name].js',
path: path.resolve( __dirname, './build/' ),
library: [ 'wc', '[name]' ],
libraryTarget: 'this',
// This fixes an issue with multiple webpack projects using chunking
// overwriting each other's chunk loader function.
// See https://webpack.js.org/configuration/output/#outputjsonpfunction
jsonpFunction: 'webpackWcBlocksJsonp',
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader?cacheDirectory',
options: {
presets: [ '@wordpress/babel-preset-default' ],
},
},
},
],
},
plugins: [
new CleanWebpackPlugin(),
new ProgressBarPlugin( {
format:
chalk.blue( 'Build core script' ) +
' [:bar] ' +
chalk.green( ':percent' ) +
' :msg (:elapsed seconds)',
} ),
new DependencyExtractionWebpackPlugin( { injectPolyfill: true } ),
],
};
/**
* Config for compiling Gutenberg blocks JS.
*/
const GutenbergBlocksConfig = {
...baseConfig,
entry: {
// Shared blocks code
blocks: './assets/js/index.js',
// Blocks
'handpicked-products':
'./assets/js/blocks/handpicked-products/index.js',
'product-best-sellers':
'./assets/js/blocks/product-best-sellers/index.js',
'product-category': './assets/js/blocks/product-category/index.js',
'product-categories': './assets/js/blocks/product-categories/index.js',
'product-new': './assets/js/blocks/product-new/index.js',
'product-on-sale': './assets/js/blocks/product-on-sale/index.js',
'product-top-rated': './assets/js/blocks/product-top-rated/index.js',
'products-by-attribute':
'./assets/js/blocks/products-by-attribute/index.js',
'featured-product': './assets/js/blocks/featured-product/index.js',
'all-reviews': './assets/js/blocks/reviews/all-reviews/index.js',
'reviews-by-product':
'./assets/js/blocks/reviews/reviews-by-product/index.js',
'reviews-by-category':
'./assets/js/blocks/reviews/reviews-by-category/index.js',
'product-search': './assets/js/blocks/product-search/index.js',
Introduce a new Products by Tag(s) block (https://github.com/woocommerce/woocommerce-blocks/pull/554) * Introduced WGPB_Extend_Core class to modify shortcodes and API requests of core * Require the new class * WC_REST_Blocks_Products_Controller_V2 to override the wc-blocks API to support new tags properties * Register new products by tag block type * Modify utils to support tags and tag_operators * Add ProductTagControl to handle tag searching * Add the actual products by tag block * Set limitTags to 100 * Create Package class and use in main plugin file * Move and refactor library class - split asset methods into new Assets class. * Add jetpack autoloader dependency * fix tests * Update from master * AbstractBlock class for general block registration * remove test autoloader so tests do not break * Create AbstractProductGrid * FeaturedProduct * HandpickedProducts * ProductBestSellers * ProductCategory * ProductNew * ProductOnSale * ProductTopRated * ProductsByAttribute * Remove old base and render functions * Allow non-dynamic blocks and register category block * Fix products-by-attribute due to wrong naming * Remove no dev * test phpunit dir * Update testing framework * Update with new abstract classes and build in API * Undo edit to attribute block * Move edit mode * No need to support shortcodes * correct linting errors * Update tests/bootstrap.php Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com> * Update code comment to make more sense. * Correct test package * docblock * Fix cancel button class * Fix classname schema * Set loading state so spinner is shown * Add placeholder element when no tags are selected * No tags placeholder * Update rest endpoints
2019-07-09 13:42:22 +00:00
'product-tag': './assets/js/blocks/product-tag/index.js',
'featured-category': './assets/js/blocks/featured-category/index.js',
},
output: {
path: path.resolve( __dirname, './build/' ),
filename: '[name].js',
library: [ 'wc', 'blocks', '[name]' ],
libraryTarget: 'this',
// This fixes an issue with multiple webpack projects using chunking
// overwriting each other's chunk loader function.
// See https://webpack.js.org/configuration/output/#outputjsonpfunction
jsonpFunction: 'webpackWcBlocksJsonp',
},
optimization: {
splitChunks: {
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all',
enforce: true,
},
editor: {
// Capture all `editor` stylesheets and the components stylesheets.
test: ( module = {} ) =>
module.constructor.name === 'CssModule' &&
( findModuleMatch( module, /editor\.scss$/ ) ||
findModuleMatch(
module,
/[\\/]assets[\\/]components[\\/]/
) ),
name: 'editor',
chunks: 'all',
priority: 10,
},
style: {
test: /style\.scss$/,
name: 'style',
chunks: 'all',
priority: 5,
},
},
},
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader?cacheDirectory',
options: {
presets: [ '@wordpress/babel-preset-default' ],
plugins: [
NODE_ENV === 'production'
? require.resolve(
'babel-plugin-transform-react-remove-prop-types'
)
: false,
require.resolve(
'@babel/plugin-proposal-class-properties'
),
].filter( Boolean ),
},
},
},
{
test: /\.s[c|a]ss$/,
use: [
'style-loader',
MiniCssExtractPlugin.loader,
{ loader: 'css-loader', options: { importLoaders: 1 } },
'postcss-loader',
{
loader: 'sass-loader',
query: {
includePaths: [ 'assets/css/abstracts' ],
data:
'@import "_colors"; ' +
'@import "_variables"; ' +
'@import "_breakpoints"; ' +
'@import "_mixins"; ',
},
},
],
},
],
},
plugins: [
new WebpackRTLPlugin( {
filename: '[name]-rtl.css',
minify: {
safe: true,
},
} ),
new MiniCssExtractPlugin( {
filename: '[name].css',
} ),
new MergeExtractFilesPlugin(
[ 'build/editor.js', 'build/style.js' ],
'build/vendors.js'
),
new ProgressBarPlugin( {
format:
chalk.blue( 'Build' ) +
' [:bar] ' +
chalk.green( ':percent' ) +
' :msg (:elapsed seconds)',
} ),
new DependencyExtractionWebpackPlugin( {
injectPolyfill: true,
requestToExternal,
requestToHandle,
} ),
],
};
const BlocksFrontendConfig = {
...baseConfig,
Create Reviews by Product block (https://github.com/woocommerce/woocommerce-blocks/pull/658) * Create Reviews by Product block * Honor Content settings * Fix wrong className * Load new wc-packages file * Add reviews-by-product JS files to webpack config * Cleanup * Remove error messages * Add Reviews by Product icon * Update sort options * Allow additional CSS classes attribute * Refactor block styles * Fix wrong default for reviews_orderby * Don't enforce CSS chunks * Add reviews count to Reviews by Product controls (https://github.com/woocommerce/woocommerce-blocks/pull/671) * Add label to Reviews by Product controls count (https://github.com/woocommerce/woocommerce-blocks/pull/677) * Add reviews count to Reviews by Product controls * Add label to Reviews by Product controls count * Add label to Reviews by Product controls count * Update components package * Review ordering and placeholders (https://github.com/woocommerce/woocommerce-blocks/pull/688) * Add support for comment_count ordering and add to productcontrol * Add a placeholder if rating count is 0 * Update assets/js/components/utils/index.js Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com> * Update assets/js/blocks/reviews-by-product/block.js Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com> * grammar * Fix some linting errors and warnings (https://github.com/woocommerce/woocommerce-blocks/pull/693) * Create Reviews by Product block placeholder (https://github.com/woocommerce/woocommerce-blocks/pull/691) * Create Reviews by Product block placeholder * Reviews by Product: load and render reviews with JS (https://github.com/woocommerce/woocommerce-blocks/pull/696) * Reviews by Product: load and render reviews with JS * Add dangerouslySetInnerHTML explanatory comment * Fix wrong dependency source * Debounce getReviews call when creating the Reviews by Product block * Rename 'Reviewer Picture' with 'Avatar' (https://github.com/woocommerce/woocommerce-blocks/pull/702) * Lint errors * Replace stringify query with addQueryArgs (https://github.com/woocommerce/woocommerce-blocks/pull/707) * Add reviews endpoint (https://github.com/woocommerce/woocommerce-blocks/pull/705) * Prevent state updates on unmounted components (https://github.com/woocommerce/woocommerce-blocks/pull/715) * Add Order by and Load more controls in Reviews by Product frontend (https://github.com/woocommerce/woocommerce-blocks/pull/716) * Export IconReviewsByProduct (https://github.com/woocommerce/woocommerce-blocks/pull/721) * Fix Reviews by Product layout in IE11 (https://github.com/woocommerce/woocommerce-blocks/pull/723) * Set minimum to per page input field (https://github.com/woocommerce/woocommerce-blocks/pull/731) * Hide avatars in Reviews by Products if 'show_avatars' settings is false (https://github.com/woocommerce/woocommerce-blocks/pull/730) * Blocks API - Reviews endpoint with rating sort and category filtering (https://github.com/woocommerce/woocommerce-blocks/pull/726) * Move file to correct location * We are only using the reviews endpoint not revioews/id * Remove sensistive data and make endpoint public * Allow guest access to approved reviews * Add support for rating sorting * category filtering * update arg name * fix category query * Reviews by Product: add placeholders when loading reviews (https://github.com/woocommerce/woocommerce-blocks/pull/732) * Add placeholder animation (https://github.com/woocommerce/woocommerce-blocks/pull/733) * Hook up Reviews by Product 'Order by' with endpoint (https://github.com/woocommerce/woocommerce-blocks/pull/736) * Hook up Reviews by Product 'Order by' with endpoint * Use onChange instead of onBlur in select control * Reviews by Product: Hide ratings if they are disabled in settings (https://github.com/woocommerce/woocommerce-blocks/pull/740) * Hide ratings in Reviews by Product if disabled in settings * Hide order by select if ratings are disabled * Reviews by Product cleanup (https://github.com/woocommerce/woocommerce-blocks/pull/773) * Fix wrong method name * Reduce the number of dependencies used in Reviews by Product (https://github.com/woocommerce/woocommerce-blocks/pull/774) * Reduce the number of dependencies used in Reviews by Product * Use 'withComponentId' HOC * Remove debounce * Fix wrong proptype * Get rid of JS warning * Load render from react-dom * Add formatted_date_created item schema (https://github.com/woocommerce/woocommerce-blocks/pull/788) * Fix import of WithComponentID * Add new settings to Reviews by Product block (https://github.com/woocommerce/woocommerce-blocks/pull/787) * Add new settings to Reviews by Product block * Remove helpText and add notices * Use RangeControl for numeric settings * Prevent fetching new reviews if all were already fetched * Enable product image in reviews * Remove unnecessary catch * Refactor getReviews * Move getReviews back to block's code * Cleanup * Fix wrong order in editor * Hide 'Load More Reviews' if showLoadMore is false * Move getReviews to utils.js * Add @woocommerce/navigation to package.json * Make notices non-dismissable * Reviews by Product: prevent importing all HOCs and import only withComponentId (https://github.com/woocommerce/woocommerce-blocks/pull/811) * Reviews by product: Update review styling and content (https://github.com/woocommerce/woocommerce-blocks/pull/806) * Add new settings to Reviews by Product block * Remove helpText and add notices * Use RangeControl for numeric settings * Prevent fetching new reviews if all were already fetched * Enable product image in reviews * Remove unnecessary catch * Refactor getReviews * Move getReviews back to block's code * Cleanup * Fix wrong order in editor * Hide 'Load More Reviews' if showLoadMore is false * Move getReviews to utils.js * Add @woocommerce/navigation to package.json * Make notices non-dismissable * Review design/layout * verified icons * Read more component * remove comment * expanded -> isExpanded * Localise and change default elipses * Simplify ReadMore * Support children rather than passing content * remove outside * remove list style * Update assets/js/components/read-more/index.js Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com> * Update assets/js/components/read-more/index.js Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com> * merge set state * Add missing parameter doc in renderReview (https://github.com/woocommerce/woocommerce-blocks/pull/820) * Fix Reviews by Product order by select not honoring default setting (https://github.com/woocommerce/woocommerce-blocks/pull/818) * Read more component - change how clamped content is shown (https://github.com/woocommerce/woocommerce-blocks/pull/821) * Pass review as components * Build summary from content and track both * Toggle display after inital load * remove unused variable * remove componentDidUpdate * Simplify clampLines * Put back componentDidUpdate, but store final summary in state * clampEnabled * Call clampLines from componentDidMount (https://github.com/woocommerce/woocommerce-blocks/pull/826) * truncate html tests * implement trimHTML and pass test * Feedback * test short content * Use withProduct HOC in ReviewsByProductEditor (https://github.com/woocommerce/woocommerce-blocks/pull/828) * Use withProduct HOC * Convert ReviewsByProductEditor to a functional component * Add loading and error states * Prevent loading screen appearing when changing products * Reviews: only save wrapper element to post (https://github.com/woocommerce/woocommerce-blocks/pull/830) * Fix bundlesize config not picking frontend files (https://github.com/woocommerce/woocommerce-blocks/pull/840) * Reviews by Product: split 'block.js' into smaller chunks (https://github.com/woocommerce/woocommerce-blocks/pull/841) * Split 'block.js' into smaller chunks * Move frontend blocks to their specific folder * Order imports * Typo * Add frontend components proptypes * Fix indentation * Call 'this.getDefaultArgs' directly inside 'getReviews' * Move access to wc_product_block_data to the top of the file * Rename 'frontend' folder to 'base' * Rename base components and move styles to their folder * Fix Reviews by Product using rating count instead of review count (https://github.com/woocommerce/woocommerce-blocks/pull/860) * Improve Reviews by Product accessibility (https://github.com/woocommerce/woocommerce-blocks/pull/861) * Improve Reviews by Product accessibility * Make 'onClick' prop not required in <LoadMoreButton> * Wrap Reviews by Product editor block with <Disabled> * Reviews: fix reviews without rating not appearing when sorting by rating (https://github.com/woocommerce/woocommerce-blocks/pull/863)
2019-08-15 14:55:57 +00:00
entry: {
'product-categories':
'./assets/js/blocks/product-categories/frontend.js',
reviews: './assets/js/blocks/reviews/frontend.js',
Create Reviews by Product block (https://github.com/woocommerce/woocommerce-blocks/pull/658) * Create Reviews by Product block * Honor Content settings * Fix wrong className * Load new wc-packages file * Add reviews-by-product JS files to webpack config * Cleanup * Remove error messages * Add Reviews by Product icon * Update sort options * Allow additional CSS classes attribute * Refactor block styles * Fix wrong default for reviews_orderby * Don't enforce CSS chunks * Add reviews count to Reviews by Product controls (https://github.com/woocommerce/woocommerce-blocks/pull/671) * Add label to Reviews by Product controls count (https://github.com/woocommerce/woocommerce-blocks/pull/677) * Add reviews count to Reviews by Product controls * Add label to Reviews by Product controls count * Add label to Reviews by Product controls count * Update components package * Review ordering and placeholders (https://github.com/woocommerce/woocommerce-blocks/pull/688) * Add support for comment_count ordering and add to productcontrol * Add a placeholder if rating count is 0 * Update assets/js/components/utils/index.js Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com> * Update assets/js/blocks/reviews-by-product/block.js Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com> * grammar * Fix some linting errors and warnings (https://github.com/woocommerce/woocommerce-blocks/pull/693) * Create Reviews by Product block placeholder (https://github.com/woocommerce/woocommerce-blocks/pull/691) * Create Reviews by Product block placeholder * Reviews by Product: load and render reviews with JS (https://github.com/woocommerce/woocommerce-blocks/pull/696) * Reviews by Product: load and render reviews with JS * Add dangerouslySetInnerHTML explanatory comment * Fix wrong dependency source * Debounce getReviews call when creating the Reviews by Product block * Rename 'Reviewer Picture' with 'Avatar' (https://github.com/woocommerce/woocommerce-blocks/pull/702) * Lint errors * Replace stringify query with addQueryArgs (https://github.com/woocommerce/woocommerce-blocks/pull/707) * Add reviews endpoint (https://github.com/woocommerce/woocommerce-blocks/pull/705) * Prevent state updates on unmounted components (https://github.com/woocommerce/woocommerce-blocks/pull/715) * Add Order by and Load more controls in Reviews by Product frontend (https://github.com/woocommerce/woocommerce-blocks/pull/716) * Export IconReviewsByProduct (https://github.com/woocommerce/woocommerce-blocks/pull/721) * Fix Reviews by Product layout in IE11 (https://github.com/woocommerce/woocommerce-blocks/pull/723) * Set minimum to per page input field (https://github.com/woocommerce/woocommerce-blocks/pull/731) * Hide avatars in Reviews by Products if 'show_avatars' settings is false (https://github.com/woocommerce/woocommerce-blocks/pull/730) * Blocks API - Reviews endpoint with rating sort and category filtering (https://github.com/woocommerce/woocommerce-blocks/pull/726) * Move file to correct location * We are only using the reviews endpoint not revioews/id * Remove sensistive data and make endpoint public * Allow guest access to approved reviews * Add support for rating sorting * category filtering * update arg name * fix category query * Reviews by Product: add placeholders when loading reviews (https://github.com/woocommerce/woocommerce-blocks/pull/732) * Add placeholder animation (https://github.com/woocommerce/woocommerce-blocks/pull/733) * Hook up Reviews by Product 'Order by' with endpoint (https://github.com/woocommerce/woocommerce-blocks/pull/736) * Hook up Reviews by Product 'Order by' with endpoint * Use onChange instead of onBlur in select control * Reviews by Product: Hide ratings if they are disabled in settings (https://github.com/woocommerce/woocommerce-blocks/pull/740) * Hide ratings in Reviews by Product if disabled in settings * Hide order by select if ratings are disabled * Reviews by Product cleanup (https://github.com/woocommerce/woocommerce-blocks/pull/773) * Fix wrong method name * Reduce the number of dependencies used in Reviews by Product (https://github.com/woocommerce/woocommerce-blocks/pull/774) * Reduce the number of dependencies used in Reviews by Product * Use 'withComponentId' HOC * Remove debounce * Fix wrong proptype * Get rid of JS warning * Load render from react-dom * Add formatted_date_created item schema (https://github.com/woocommerce/woocommerce-blocks/pull/788) * Fix import of WithComponentID * Add new settings to Reviews by Product block (https://github.com/woocommerce/woocommerce-blocks/pull/787) * Add new settings to Reviews by Product block * Remove helpText and add notices * Use RangeControl for numeric settings * Prevent fetching new reviews if all were already fetched * Enable product image in reviews * Remove unnecessary catch * Refactor getReviews * Move getReviews back to block's code * Cleanup * Fix wrong order in editor * Hide 'Load More Reviews' if showLoadMore is false * Move getReviews to utils.js * Add @woocommerce/navigation to package.json * Make notices non-dismissable * Reviews by Product: prevent importing all HOCs and import only withComponentId (https://github.com/woocommerce/woocommerce-blocks/pull/811) * Reviews by product: Update review styling and content (https://github.com/woocommerce/woocommerce-blocks/pull/806) * Add new settings to Reviews by Product block * Remove helpText and add notices * Use RangeControl for numeric settings * Prevent fetching new reviews if all were already fetched * Enable product image in reviews * Remove unnecessary catch * Refactor getReviews * Move getReviews back to block's code * Cleanup * Fix wrong order in editor * Hide 'Load More Reviews' if showLoadMore is false * Move getReviews to utils.js * Add @woocommerce/navigation to package.json * Make notices non-dismissable * Review design/layout * verified icons * Read more component * remove comment * expanded -> isExpanded * Localise and change default elipses * Simplify ReadMore * Support children rather than passing content * remove outside * remove list style * Update assets/js/components/read-more/index.js Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com> * Update assets/js/components/read-more/index.js Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com> * merge set state * Add missing parameter doc in renderReview (https://github.com/woocommerce/woocommerce-blocks/pull/820) * Fix Reviews by Product order by select not honoring default setting (https://github.com/woocommerce/woocommerce-blocks/pull/818) * Read more component - change how clamped content is shown (https://github.com/woocommerce/woocommerce-blocks/pull/821) * Pass review as components * Build summary from content and track both * Toggle display after inital load * remove unused variable * remove componentDidUpdate * Simplify clampLines * Put back componentDidUpdate, but store final summary in state * clampEnabled * Call clampLines from componentDidMount (https://github.com/woocommerce/woocommerce-blocks/pull/826) * truncate html tests * implement trimHTML and pass test * Feedback * test short content * Use withProduct HOC in ReviewsByProductEditor (https://github.com/woocommerce/woocommerce-blocks/pull/828) * Use withProduct HOC * Convert ReviewsByProductEditor to a functional component * Add loading and error states * Prevent loading screen appearing when changing products * Reviews: only save wrapper element to post (https://github.com/woocommerce/woocommerce-blocks/pull/830) * Fix bundlesize config not picking frontend files (https://github.com/woocommerce/woocommerce-blocks/pull/840) * Reviews by Product: split 'block.js' into smaller chunks (https://github.com/woocommerce/woocommerce-blocks/pull/841) * Split 'block.js' into smaller chunks * Move frontend blocks to their specific folder * Order imports * Typo * Add frontend components proptypes * Fix indentation * Call 'this.getDefaultArgs' directly inside 'getReviews' * Move access to wc_product_block_data to the top of the file * Rename 'frontend' folder to 'base' * Rename base components and move styles to their folder * Fix Reviews by Product using rating count instead of review count (https://github.com/woocommerce/woocommerce-blocks/pull/860) * Improve Reviews by Product accessibility (https://github.com/woocommerce/woocommerce-blocks/pull/861) * Improve Reviews by Product accessibility * Make 'onClick' prop not required in <LoadMoreButton> * Wrap Reviews by Product editor block with <Disabled> * Reviews: fix reviews without rating not appearing when sorting by rating (https://github.com/woocommerce/woocommerce-blocks/pull/863)
2019-08-15 14:55:57 +00:00
},
output: {
path: path.resolve( __dirname, './build/' ),
Create Reviews by Product block (https://github.com/woocommerce/woocommerce-blocks/pull/658) * Create Reviews by Product block * Honor Content settings * Fix wrong className * Load new wc-packages file * Add reviews-by-product JS files to webpack config * Cleanup * Remove error messages * Add Reviews by Product icon * Update sort options * Allow additional CSS classes attribute * Refactor block styles * Fix wrong default for reviews_orderby * Don't enforce CSS chunks * Add reviews count to Reviews by Product controls (https://github.com/woocommerce/woocommerce-blocks/pull/671) * Add label to Reviews by Product controls count (https://github.com/woocommerce/woocommerce-blocks/pull/677) * Add reviews count to Reviews by Product controls * Add label to Reviews by Product controls count * Add label to Reviews by Product controls count * Update components package * Review ordering and placeholders (https://github.com/woocommerce/woocommerce-blocks/pull/688) * Add support for comment_count ordering and add to productcontrol * Add a placeholder if rating count is 0 * Update assets/js/components/utils/index.js Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com> * Update assets/js/blocks/reviews-by-product/block.js Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com> * grammar * Fix some linting errors and warnings (https://github.com/woocommerce/woocommerce-blocks/pull/693) * Create Reviews by Product block placeholder (https://github.com/woocommerce/woocommerce-blocks/pull/691) * Create Reviews by Product block placeholder * Reviews by Product: load and render reviews with JS (https://github.com/woocommerce/woocommerce-blocks/pull/696) * Reviews by Product: load and render reviews with JS * Add dangerouslySetInnerHTML explanatory comment * Fix wrong dependency source * Debounce getReviews call when creating the Reviews by Product block * Rename 'Reviewer Picture' with 'Avatar' (https://github.com/woocommerce/woocommerce-blocks/pull/702) * Lint errors * Replace stringify query with addQueryArgs (https://github.com/woocommerce/woocommerce-blocks/pull/707) * Add reviews endpoint (https://github.com/woocommerce/woocommerce-blocks/pull/705) * Prevent state updates on unmounted components (https://github.com/woocommerce/woocommerce-blocks/pull/715) * Add Order by and Load more controls in Reviews by Product frontend (https://github.com/woocommerce/woocommerce-blocks/pull/716) * Export IconReviewsByProduct (https://github.com/woocommerce/woocommerce-blocks/pull/721) * Fix Reviews by Product layout in IE11 (https://github.com/woocommerce/woocommerce-blocks/pull/723) * Set minimum to per page input field (https://github.com/woocommerce/woocommerce-blocks/pull/731) * Hide avatars in Reviews by Products if 'show_avatars' settings is false (https://github.com/woocommerce/woocommerce-blocks/pull/730) * Blocks API - Reviews endpoint with rating sort and category filtering (https://github.com/woocommerce/woocommerce-blocks/pull/726) * Move file to correct location * We are only using the reviews endpoint not revioews/id * Remove sensistive data and make endpoint public * Allow guest access to approved reviews * Add support for rating sorting * category filtering * update arg name * fix category query * Reviews by Product: add placeholders when loading reviews (https://github.com/woocommerce/woocommerce-blocks/pull/732) * Add placeholder animation (https://github.com/woocommerce/woocommerce-blocks/pull/733) * Hook up Reviews by Product 'Order by' with endpoint (https://github.com/woocommerce/woocommerce-blocks/pull/736) * Hook up Reviews by Product 'Order by' with endpoint * Use onChange instead of onBlur in select control * Reviews by Product: Hide ratings if they are disabled in settings (https://github.com/woocommerce/woocommerce-blocks/pull/740) * Hide ratings in Reviews by Product if disabled in settings * Hide order by select if ratings are disabled * Reviews by Product cleanup (https://github.com/woocommerce/woocommerce-blocks/pull/773) * Fix wrong method name * Reduce the number of dependencies used in Reviews by Product (https://github.com/woocommerce/woocommerce-blocks/pull/774) * Reduce the number of dependencies used in Reviews by Product * Use 'withComponentId' HOC * Remove debounce * Fix wrong proptype * Get rid of JS warning * Load render from react-dom * Add formatted_date_created item schema (https://github.com/woocommerce/woocommerce-blocks/pull/788) * Fix import of WithComponentID * Add new settings to Reviews by Product block (https://github.com/woocommerce/woocommerce-blocks/pull/787) * Add new settings to Reviews by Product block * Remove helpText and add notices * Use RangeControl for numeric settings * Prevent fetching new reviews if all were already fetched * Enable product image in reviews * Remove unnecessary catch * Refactor getReviews * Move getReviews back to block's code * Cleanup * Fix wrong order in editor * Hide 'Load More Reviews' if showLoadMore is false * Move getReviews to utils.js * Add @woocommerce/navigation to package.json * Make notices non-dismissable * Reviews by Product: prevent importing all HOCs and import only withComponentId (https://github.com/woocommerce/woocommerce-blocks/pull/811) * Reviews by product: Update review styling and content (https://github.com/woocommerce/woocommerce-blocks/pull/806) * Add new settings to Reviews by Product block * Remove helpText and add notices * Use RangeControl for numeric settings * Prevent fetching new reviews if all were already fetched * Enable product image in reviews * Remove unnecessary catch * Refactor getReviews * Move getReviews back to block's code * Cleanup * Fix wrong order in editor * Hide 'Load More Reviews' if showLoadMore is false * Move getReviews to utils.js * Add @woocommerce/navigation to package.json * Make notices non-dismissable * Review design/layout * verified icons * Read more component * remove comment * expanded -> isExpanded * Localise and change default elipses * Simplify ReadMore * Support children rather than passing content * remove outside * remove list style * Update assets/js/components/read-more/index.js Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com> * Update assets/js/components/read-more/index.js Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com> * merge set state * Add missing parameter doc in renderReview (https://github.com/woocommerce/woocommerce-blocks/pull/820) * Fix Reviews by Product order by select not honoring default setting (https://github.com/woocommerce/woocommerce-blocks/pull/818) * Read more component - change how clamped content is shown (https://github.com/woocommerce/woocommerce-blocks/pull/821) * Pass review as components * Build summary from content and track both * Toggle display after inital load * remove unused variable * remove componentDidUpdate * Simplify clampLines * Put back componentDidUpdate, but store final summary in state * clampEnabled * Call clampLines from componentDidMount (https://github.com/woocommerce/woocommerce-blocks/pull/826) * truncate html tests * implement trimHTML and pass test * Feedback * test short content * Use withProduct HOC in ReviewsByProductEditor (https://github.com/woocommerce/woocommerce-blocks/pull/828) * Use withProduct HOC * Convert ReviewsByProductEditor to a functional component * Add loading and error states * Prevent loading screen appearing when changing products * Reviews: only save wrapper element to post (https://github.com/woocommerce/woocommerce-blocks/pull/830) * Fix bundlesize config not picking frontend files (https://github.com/woocommerce/woocommerce-blocks/pull/840) * Reviews by Product: split 'block.js' into smaller chunks (https://github.com/woocommerce/woocommerce-blocks/pull/841) * Split 'block.js' into smaller chunks * Move frontend blocks to their specific folder * Order imports * Typo * Add frontend components proptypes * Fix indentation * Call 'this.getDefaultArgs' directly inside 'getReviews' * Move access to wc_product_block_data to the top of the file * Rename 'frontend' folder to 'base' * Rename base components and move styles to their folder * Fix Reviews by Product using rating count instead of review count (https://github.com/woocommerce/woocommerce-blocks/pull/860) * Improve Reviews by Product accessibility (https://github.com/woocommerce/woocommerce-blocks/pull/861) * Improve Reviews by Product accessibility * Make 'onClick' prop not required in <LoadMoreButton> * Wrap Reviews by Product editor block with <Disabled> * Reviews: fix reviews without rating not appearing when sorting by rating (https://github.com/woocommerce/woocommerce-blocks/pull/863)
2019-08-15 14:55:57 +00:00
filename: '[name]-frontend.js',
// This fixes an issue with multiple webpack projects using chunking
// overwriting each other's chunk loader function.
// See https://webpack.js.org/configuration/output/#outputjsonpfunction
jsonpFunction: 'webpackWcBlocksJsonp',
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader?cacheDirectory',
options: {
2019-07-31 13:59:07 +00:00
presets: [
[
'@babel/preset-env',
{
modules: false,
targets: {
browsers: [
'extends @wordpress/browserslist-config',
],
},
2019-07-31 13:59:07 +00:00
},
],
],
2019-07-31 13:59:07 +00:00
plugins: [
require.resolve(
'@babel/plugin-proposal-object-rest-spread'
),
require.resolve(
'@babel/plugin-transform-react-jsx'
),
require.resolve(
'@babel/plugin-proposal-async-generator-functions'
),
require.resolve(
'@babel/plugin-transform-runtime'
),
require.resolve(
'@babel/plugin-proposal-class-properties'
),
NODE_ENV === 'production'
? require.resolve(
'babel-plugin-transform-react-remove-prop-types'
)
: false,
2019-07-31 13:59:07 +00:00
].filter( Boolean ),
},
},
},
Create Reviews by Product block (https://github.com/woocommerce/woocommerce-blocks/pull/658) * Create Reviews by Product block * Honor Content settings * Fix wrong className * Load new wc-packages file * Add reviews-by-product JS files to webpack config * Cleanup * Remove error messages * Add Reviews by Product icon * Update sort options * Allow additional CSS classes attribute * Refactor block styles * Fix wrong default for reviews_orderby * Don't enforce CSS chunks * Add reviews count to Reviews by Product controls (https://github.com/woocommerce/woocommerce-blocks/pull/671) * Add label to Reviews by Product controls count (https://github.com/woocommerce/woocommerce-blocks/pull/677) * Add reviews count to Reviews by Product controls * Add label to Reviews by Product controls count * Add label to Reviews by Product controls count * Update components package * Review ordering and placeholders (https://github.com/woocommerce/woocommerce-blocks/pull/688) * Add support for comment_count ordering and add to productcontrol * Add a placeholder if rating count is 0 * Update assets/js/components/utils/index.js Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com> * Update assets/js/blocks/reviews-by-product/block.js Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com> * grammar * Fix some linting errors and warnings (https://github.com/woocommerce/woocommerce-blocks/pull/693) * Create Reviews by Product block placeholder (https://github.com/woocommerce/woocommerce-blocks/pull/691) * Create Reviews by Product block placeholder * Reviews by Product: load and render reviews with JS (https://github.com/woocommerce/woocommerce-blocks/pull/696) * Reviews by Product: load and render reviews with JS * Add dangerouslySetInnerHTML explanatory comment * Fix wrong dependency source * Debounce getReviews call when creating the Reviews by Product block * Rename 'Reviewer Picture' with 'Avatar' (https://github.com/woocommerce/woocommerce-blocks/pull/702) * Lint errors * Replace stringify query with addQueryArgs (https://github.com/woocommerce/woocommerce-blocks/pull/707) * Add reviews endpoint (https://github.com/woocommerce/woocommerce-blocks/pull/705) * Prevent state updates on unmounted components (https://github.com/woocommerce/woocommerce-blocks/pull/715) * Add Order by and Load more controls in Reviews by Product frontend (https://github.com/woocommerce/woocommerce-blocks/pull/716) * Export IconReviewsByProduct (https://github.com/woocommerce/woocommerce-blocks/pull/721) * Fix Reviews by Product layout in IE11 (https://github.com/woocommerce/woocommerce-blocks/pull/723) * Set minimum to per page input field (https://github.com/woocommerce/woocommerce-blocks/pull/731) * Hide avatars in Reviews by Products if 'show_avatars' settings is false (https://github.com/woocommerce/woocommerce-blocks/pull/730) * Blocks API - Reviews endpoint with rating sort and category filtering (https://github.com/woocommerce/woocommerce-blocks/pull/726) * Move file to correct location * We are only using the reviews endpoint not revioews/id * Remove sensistive data and make endpoint public * Allow guest access to approved reviews * Add support for rating sorting * category filtering * update arg name * fix category query * Reviews by Product: add placeholders when loading reviews (https://github.com/woocommerce/woocommerce-blocks/pull/732) * Add placeholder animation (https://github.com/woocommerce/woocommerce-blocks/pull/733) * Hook up Reviews by Product 'Order by' with endpoint (https://github.com/woocommerce/woocommerce-blocks/pull/736) * Hook up Reviews by Product 'Order by' with endpoint * Use onChange instead of onBlur in select control * Reviews by Product: Hide ratings if they are disabled in settings (https://github.com/woocommerce/woocommerce-blocks/pull/740) * Hide ratings in Reviews by Product if disabled in settings * Hide order by select if ratings are disabled * Reviews by Product cleanup (https://github.com/woocommerce/woocommerce-blocks/pull/773) * Fix wrong method name * Reduce the number of dependencies used in Reviews by Product (https://github.com/woocommerce/woocommerce-blocks/pull/774) * Reduce the number of dependencies used in Reviews by Product * Use 'withComponentId' HOC * Remove debounce * Fix wrong proptype * Get rid of JS warning * Load render from react-dom * Add formatted_date_created item schema (https://github.com/woocommerce/woocommerce-blocks/pull/788) * Fix import of WithComponentID * Add new settings to Reviews by Product block (https://github.com/woocommerce/woocommerce-blocks/pull/787) * Add new settings to Reviews by Product block * Remove helpText and add notices * Use RangeControl for numeric settings * Prevent fetching new reviews if all were already fetched * Enable product image in reviews * Remove unnecessary catch * Refactor getReviews * Move getReviews back to block's code * Cleanup * Fix wrong order in editor * Hide 'Load More Reviews' if showLoadMore is false * Move getReviews to utils.js * Add @woocommerce/navigation to package.json * Make notices non-dismissable * Reviews by Product: prevent importing all HOCs and import only withComponentId (https://github.com/woocommerce/woocommerce-blocks/pull/811) * Reviews by product: Update review styling and content (https://github.com/woocommerce/woocommerce-blocks/pull/806) * Add new settings to Reviews by Product block * Remove helpText and add notices * Use RangeControl for numeric settings * Prevent fetching new reviews if all were already fetched * Enable product image in reviews * Remove unnecessary catch * Refactor getReviews * Move getReviews back to block's code * Cleanup * Fix wrong order in editor * Hide 'Load More Reviews' if showLoadMore is false * Move getReviews to utils.js * Add @woocommerce/navigation to package.json * Make notices non-dismissable * Review design/layout * verified icons * Read more component * remove comment * expanded -> isExpanded * Localise and change default elipses * Simplify ReadMore * Support children rather than passing content * remove outside * remove list style * Update assets/js/components/read-more/index.js Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com> * Update assets/js/components/read-more/index.js Co-Authored-By: Albert Juhé Lluveras <contact@albertjuhe.com> * merge set state * Add missing parameter doc in renderReview (https://github.com/woocommerce/woocommerce-blocks/pull/820) * Fix Reviews by Product order by select not honoring default setting (https://github.com/woocommerce/woocommerce-blocks/pull/818) * Read more component - change how clamped content is shown (https://github.com/woocommerce/woocommerce-blocks/pull/821) * Pass review as components * Build summary from content and track both * Toggle display after inital load * remove unused variable * remove componentDidUpdate * Simplify clampLines * Put back componentDidUpdate, but store final summary in state * clampEnabled * Call clampLines from componentDidMount (https://github.com/woocommerce/woocommerce-blocks/pull/826) * truncate html tests * implement trimHTML and pass test * Feedback * test short content * Use withProduct HOC in ReviewsByProductEditor (https://github.com/woocommerce/woocommerce-blocks/pull/828) * Use withProduct HOC * Convert ReviewsByProductEditor to a functional component * Add loading and error states * Prevent loading screen appearing when changing products * Reviews: only save wrapper element to post (https://github.com/woocommerce/woocommerce-blocks/pull/830) * Fix bundlesize config not picking frontend files (https://github.com/woocommerce/woocommerce-blocks/pull/840) * Reviews by Product: split 'block.js' into smaller chunks (https://github.com/woocommerce/woocommerce-blocks/pull/841) * Split 'block.js' into smaller chunks * Move frontend blocks to their specific folder * Order imports * Typo * Add frontend components proptypes * Fix indentation * Call 'this.getDefaultArgs' directly inside 'getReviews' * Move access to wc_product_block_data to the top of the file * Rename 'frontend' folder to 'base' * Rename base components and move styles to their folder * Fix Reviews by Product using rating count instead of review count (https://github.com/woocommerce/woocommerce-blocks/pull/860) * Improve Reviews by Product accessibility (https://github.com/woocommerce/woocommerce-blocks/pull/861) * Improve Reviews by Product accessibility * Make 'onClick' prop not required in <LoadMoreButton> * Wrap Reviews by Product editor block with <Disabled> * Reviews: fix reviews without rating not appearing when sorting by rating (https://github.com/woocommerce/woocommerce-blocks/pull/863)
2019-08-15 14:55:57 +00:00
{
test: /\.s[c|a]ss$/,
use: {
loader: 'ignore-loader',
},
},
],
},
plugins: [
new ProgressBarPlugin( {
format:
chalk.blue( 'Build frontend scripts' ) +
' [:bar] ' +
chalk.green( ':percent' ) +
' :msg (:elapsed seconds)',
} ),
new DependencyExtractionWebpackPlugin( {
injectPolyfill: true,
requestToExternal,
requestToHandle,
} ),
],
};
module.exports = [ CoreConfig, GutenbergBlocksConfig, BlocksFrontendConfig ];