2021-08-19 14:15:59 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2022-03-18 10:59:05 +00:00
|
|
|
const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' );
|
2021-08-19 14:15:59 +00:00
|
|
|
const path = require( 'path' );
|
|
|
|
const WebpackRTLPlugin = require( 'webpack-rtl-plugin' );
|
2022-03-18 10:59:05 +00:00
|
|
|
const RemoveEmptyScriptsPlugin = require( 'webpack-remove-empty-scripts' );
|
2021-08-19 14:15:59 +00:00
|
|
|
const postcssPlugins = require( '@wordpress/postcss-plugins-preset' );
|
2024-02-27 08:07:53 +00:00
|
|
|
const StyleAssetPlugin = require( './style-asset-plugin' );
|
2021-08-19 14:15:59 +00:00
|
|
|
|
2024-10-15 06:21:56 +00:00
|
|
|
/**
|
|
|
|
* @deprecated intended for React version migration and can be dropped from exports any time without further notice.
|
|
|
|
*/
|
|
|
|
const ForkTsCheckerWebpackPlugin = require( 'fork-ts-checker-webpack-plugin' );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* https://github.com/woocommerce/woocommerce/pull/47486: do not break build if TS emits errors - React 18 migration related.
|
|
|
|
* The solution is based on https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/issues/232#issuecomment-1322651312.
|
|
|
|
*
|
|
|
|
* @deprecated intended for React version migration and can be dropped from exports any time without further notice.
|
|
|
|
*/
|
|
|
|
class TypeScriptWarnOnlyWebpackPlugin {
|
|
|
|
constructor( error_codes ) {
|
|
|
|
this.error_codes = error_codes;
|
|
|
|
}
|
|
|
|
|
|
|
|
apply( compiler ) {
|
|
|
|
const codes = this.error_codes;
|
|
|
|
const hooks = ForkTsCheckerWebpackPlugin.getCompilerHooks( compiler );
|
|
|
|
hooks.issues.tap( 'TypeScriptWarnOnlyWebpackPlugin', ( issues ) =>
|
|
|
|
issues.map( function ( issue ) {
|
|
|
|
const mutate =
|
|
|
|
issue.severity === 'error' && codes.includes( issue.code );
|
|
|
|
return {
|
|
|
|
...issue,
|
|
|
|
severity: mutate ? 'warning' : issue.severity,
|
|
|
|
};
|
|
|
|
} )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-19 14:15:59 +00:00
|
|
|
const NODE_ENV = process.env.NODE_ENV || 'development';
|
|
|
|
|
|
|
|
module.exports = {
|
Update to pnpm 9.1 (#47385)
* Update to pnpm 9.1 and fix a mini css bug
* Add changefile(s) from automation for the following project(s): @woocommerce/tracks, @woocommerce/product-editor, @woocommerce/onboarding, @woocommerce/number, @woocommerce/notices, @woocommerce/navigation, @woocommerce/internal-js-tests, @woocommerce/extend-cart-checkout-block, @woocommerce/expression-evaluation, @woocommerce/explat, @woocommerce/experimental, @woocommerce/eslint-plugin, @woocommerce/dependency-extraction-webpack-plugin, @woocommerce/date, @woocommerce/data, @woocommerce/customer-effort-score, @woocommerce/currency, @woocommerce/csv-export, @woocommerce/create-woo-extension, @woocommerce/create-product-editor-block, @woocommerce/components, @woocommerce/api, @woocommerce/ai, @woocommerce/admin-e2e-tests, woocommerce-blocks, woocommerce-beta-tester, woocommerce, woo-ai
* temporarily disable swallowing build output to diagnose issue with perf workflow
* Ignore some type issues that commonly resurface when deps slightly change
* Fix persistent type issues that have recurred many times
* Add more ignores
* Fix lint issue
* Revert change to swallow build error
* Improve access of the config that needs updated build dir.
---------
Co-authored-by: github-actions <github-actions@github.com>
2024-05-13 13:57:39 +00:00
|
|
|
plugin: MiniCssExtractPlugin,
|
2021-08-19 14:15:59 +00:00
|
|
|
webpackConfig: {
|
2023-03-27 01:42:33 +00:00
|
|
|
parser: {
|
|
|
|
javascript: {
|
|
|
|
exportsPresence: 'error',
|
|
|
|
},
|
|
|
|
},
|
2021-08-19 14:15:59 +00:00
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.s?css$/,
|
2024-07-29 13:20:17 +00:00
|
|
|
exclude: [
|
|
|
|
/storybook\/wordpress/,
|
|
|
|
/build-style\/*\/*.css/,
|
2024-10-23 11:48:36 +00:00
|
|
|
/[\/\\](changelog|bin|docs|build|build-module|build-types|build-style|vendor|tests|test)[\/\\]/,
|
2024-07-29 13:20:17 +00:00
|
|
|
],
|
2021-08-19 14:15:59 +00:00
|
|
|
use: [
|
|
|
|
MiniCssExtractPlugin.loader,
|
|
|
|
'css-loader',
|
|
|
|
{
|
|
|
|
loader: 'postcss-loader',
|
|
|
|
options: {
|
2023-03-08 21:13:25 +00:00
|
|
|
postcssOptions: {
|
|
|
|
plugins: postcssPlugins,
|
|
|
|
},
|
2021-08-19 14:15:59 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'sass-loader',
|
|
|
|
options: {
|
|
|
|
sassOptions: {
|
|
|
|
includePaths: [
|
|
|
|
path.resolve( __dirname, 'abstracts' ),
|
|
|
|
],
|
|
|
|
},
|
|
|
|
webpackImporter: true,
|
2022-06-08 09:16:31 +00:00
|
|
|
additionalData: ( content, loaderContext ) => {
|
|
|
|
const { resourcePath } = loaderContext;
|
|
|
|
if ( resourcePath.includes( '@automattic+' ) ) {
|
|
|
|
/*
|
|
|
|
* Skip adding additional data for @automattic/* packages to
|
|
|
|
* fix "SassError: @use rules must be written before any other rules."
|
|
|
|
* @automattic/* packages have included '@use "sass:math" and other necessary imports.
|
|
|
|
*/
|
|
|
|
return content;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
'@use "sass:math";' +
|
|
|
|
'@import "_colors"; ' +
|
|
|
|
'@import "_variables"; ' +
|
|
|
|
'@import "_breakpoints"; ' +
|
|
|
|
'@import "_mixins"; ' +
|
|
|
|
content
|
|
|
|
);
|
|
|
|
},
|
2021-08-19 14:15:59 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
plugins: [
|
2022-03-18 10:59:05 +00:00
|
|
|
new RemoveEmptyScriptsPlugin(),
|
2021-08-19 14:15:59 +00:00
|
|
|
new MiniCssExtractPlugin( {
|
|
|
|
filename: '[name]/style.css',
|
2024-02-27 08:07:53 +00:00
|
|
|
chunkFilename: 'chunks/[id].style.css?ver=[contenthash]',
|
2021-08-19 14:15:59 +00:00
|
|
|
} ),
|
|
|
|
new WebpackRTLPlugin( {
|
|
|
|
filename: '[name]/style-rtl.css',
|
|
|
|
minify: NODE_ENV === 'development' ? false : { safe: true },
|
|
|
|
} ),
|
2024-02-27 08:07:53 +00:00
|
|
|
new StyleAssetPlugin(),
|
2021-08-19 14:15:59 +00:00
|
|
|
],
|
|
|
|
},
|
2024-02-27 08:07:53 +00:00
|
|
|
StyleAssetPlugin,
|
2024-10-15 06:21:56 +00:00
|
|
|
ForkTsCheckerWebpackPlugin,
|
|
|
|
TypeScriptWarnOnlyWebpackPlugin,
|
2021-08-19 14:15:59 +00:00
|
|
|
};
|