diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 00000000..2401f746 --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,5 @@ +// Import the default config file and expose it in the project root. +// Useful for editor integrations. +module.exports = { + ...require( '@wordpress/prettier-config' ), +}; diff --git a/package-lock.json b/package-lock.json index 0997143e..11f063b6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,7 +4,6 @@ "requires": true, "packages": { "": { - "name": "secure-custom-fields", "dependencies": { "md5": "^2.3.0" }, @@ -14,6 +13,7 @@ "@babel/preset-react": "^7.25.7", "@wordpress/dependency-extraction-webpack-plugin": "^6.20.0", "@wordpress/e2e-test-utils-playwright": "^1.20.0", + "@wordpress/prettier-config": "^4.22.0", "@wordpress/scripts": "^30.14.0", "babel-loader": "^9.2.1", "css-loader": "^7.1.2", @@ -5059,9 +5059,9 @@ } }, "node_modules/@wordpress/prettier-config": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/@wordpress/prettier-config/-/prettier-config-4.21.0.tgz", - "integrity": "sha512-UzM/ZtZAR7kLszn124bPa7PDlVT2cPgi+z0wyt95+c2Lg8aNz5O00L5Vxrjcql5gN36uPoQfXj+5CgG1XFiZEQ==", + "version": "4.22.0", + "resolved": "https://registry.npmjs.org/@wordpress/prettier-config/-/prettier-config-4.22.0.tgz", + "integrity": "sha512-+XsgTyVSrPd7m+s4G/fNBuyzvkE/Dgx3syUn5G5KLhnb5atRb4r1hWrLBg/oC8vsU5kGEyO+p6LEDRjcZtl0nQ==", "dev": true, "license": "GPL-2.0-or-later", "engines": { diff --git a/package.json b/package.json index 3135489a..a976d8a9 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "@babel/preset-react": "^7.25.7", "@wordpress/dependency-extraction-webpack-plugin": "^6.20.0", "@wordpress/e2e-test-utils-playwright": "^1.20.0", + "@wordpress/prettier-config": "^4.22.0", "@wordpress/scripts": "^30.14.0", "babel-loader": "^9.2.1", "css-loader": "^7.1.2", diff --git a/webpack.config.js b/webpack.config.js index f82cbb57..e44cab84 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,9 +1,9 @@ -const path = require('path'); -const TerserPlugin = require('terser-webpack-plugin'); -const MiniCssExtractPlugin = require('mini-css-extract-plugin'); -const CssMinimizerPlugin = require('css-minimizer-webpack-plugin'); -const RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts'); -const DependencyExtractionWebpackPlugin = require('@wordpress/dependency-extraction-webpack-plugin'); +const path = require( 'path' ); +const TerserPlugin = require( 'terser-webpack-plugin' ); +const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' ); +const CssMinimizerPlugin = require( 'css-minimizer-webpack-plugin' ); +const RemoveEmptyScriptsPlugin = require( 'webpack-remove-empty-scripts' ); +const DependencyExtractionWebpackPlugin = require( '@wordpress/dependency-extraction-webpack-plugin' ); // Common configuration for both builds const commonConfig = { @@ -33,7 +33,7 @@ const commonConfig = { 'css/pro/acf-pro-input': './assets/src/sass/pro/acf-pro-input.scss', }, output: { - path: path.resolve(__dirname, 'assets/build/'), + path: path.resolve( __dirname, 'assets/build/' ), }, module: { rules: [ @@ -43,7 +43,7 @@ const commonConfig = { use: { loader: 'babel-loader', options: { - presets: ['@babel/preset-react'], + presets: [ '@babel/preset-react' ], }, }, }, @@ -78,13 +78,13 @@ const unminifiedConfig = { }, plugins: [ new RemoveEmptyScriptsPlugin(), - new MiniCssExtractPlugin({ + new MiniCssExtractPlugin( { filename: '[name].css', // Output CSS as .css - }), - new DependencyExtractionWebpackPlugin({ + } ), + new DependencyExtractionWebpackPlugin( { injectPolyfill: true, useCombinedAssetFile: true, - }), + } ), ], }; @@ -99,28 +99,28 @@ const minifiedConfig = { optimization: { minimize: true, // Enable minification minimizer: [ - new TerserPlugin({ + new TerserPlugin( { terserOptions: { format: { comments: false, // Remove comments }, }, extractComments: false, - }), + } ), new CssMinimizerPlugin(), // Minify CSS ], }, plugins: [ new RemoveEmptyScriptsPlugin(), - new MiniCssExtractPlugin({ + new MiniCssExtractPlugin( { filename: '[name].min.css', // Changed to output .min.css files - }), - new DependencyExtractionWebpackPlugin({ + } ), + new DependencyExtractionWebpackPlugin( { injectPolyfill: true, useCombinedAssetFile: true, - }), + } ), ], }; // Export both configurations -module.exports = [unminifiedConfig, minifiedConfig]; \ No newline at end of file +module.exports = [ unminifiedConfig, minifiedConfig ];