Skip to content

Commit 6a1b9b6

Browse files
authored
Add prettier (#115)
1 parent 10d896b commit 6a1b9b6

File tree

4 files changed

+29
-23
lines changed

4 files changed

+29
-23
lines changed

.prettierrc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Import the default config file and expose it in the project root.
2+
// Useful for editor integrations.
3+
module.exports = {
4+
...require( '@wordpress/prettier-config' ),
5+
};

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"@babel/preset-react": "^7.25.7",
2020
"@wordpress/dependency-extraction-webpack-plugin": "^6.20.0",
2121
"@wordpress/e2e-test-utils-playwright": "^1.20.0",
22+
"@wordpress/prettier-config": "^4.22.0",
2223
"@wordpress/scripts": "^30.14.0",
2324
"babel-loader": "^9.2.1",
2425
"css-loader": "^7.1.2",

webpack.config.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
const path = require('path');
2-
const TerserPlugin = require('terser-webpack-plugin');
3-
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
4-
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
5-
const RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts');
6-
const DependencyExtractionWebpackPlugin = require('@wordpress/dependency-extraction-webpack-plugin');
1+
const path = require( 'path' );
2+
const TerserPlugin = require( 'terser-webpack-plugin' );
3+
const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' );
4+
const CssMinimizerPlugin = require( 'css-minimizer-webpack-plugin' );
5+
const RemoveEmptyScriptsPlugin = require( 'webpack-remove-empty-scripts' );
6+
const DependencyExtractionWebpackPlugin = require( '@wordpress/dependency-extraction-webpack-plugin' );
77

88
// Common configuration for both builds
99
const commonConfig = {
@@ -33,7 +33,7 @@ const commonConfig = {
3333
'css/pro/acf-pro-input': './assets/src/sass/pro/acf-pro-input.scss',
3434
},
3535
output: {
36-
path: path.resolve(__dirname, 'assets/build/'),
36+
path: path.resolve( __dirname, 'assets/build/' ),
3737
},
3838
module: {
3939
rules: [
@@ -43,7 +43,7 @@ const commonConfig = {
4343
use: {
4444
loader: 'babel-loader',
4545
options: {
46-
presets: ['@babel/preset-react'],
46+
presets: [ '@babel/preset-react' ],
4747
},
4848
},
4949
},
@@ -78,13 +78,13 @@ const unminifiedConfig = {
7878
},
7979
plugins: [
8080
new RemoveEmptyScriptsPlugin(),
81-
new MiniCssExtractPlugin({
81+
new MiniCssExtractPlugin( {
8282
filename: '[name].css', // Output CSS as .css
83-
}),
84-
new DependencyExtractionWebpackPlugin({
83+
} ),
84+
new DependencyExtractionWebpackPlugin( {
8585
injectPolyfill: true,
8686
useCombinedAssetFile: true,
87-
}),
87+
} ),
8888
],
8989
};
9090

@@ -99,28 +99,28 @@ const minifiedConfig = {
9999
optimization: {
100100
minimize: true, // Enable minification
101101
minimizer: [
102-
new TerserPlugin({
102+
new TerserPlugin( {
103103
terserOptions: {
104104
format: {
105105
comments: false, // Remove comments
106106
},
107107
},
108108
extractComments: false,
109-
}),
109+
} ),
110110
new CssMinimizerPlugin(), // Minify CSS
111111
],
112112
},
113113
plugins: [
114114
new RemoveEmptyScriptsPlugin(),
115-
new MiniCssExtractPlugin({
115+
new MiniCssExtractPlugin( {
116116
filename: '[name].min.css', // Changed to output .min.css files
117-
}),
118-
new DependencyExtractionWebpackPlugin({
117+
} ),
118+
new DependencyExtractionWebpackPlugin( {
119119
injectPolyfill: true,
120120
useCombinedAssetFile: true,
121-
}),
121+
} ),
122122
],
123123
};
124124

125125
// Export both configurations
126-
module.exports = [unminifiedConfig, minifiedConfig];
126+
module.exports = [ unminifiedConfig, minifiedConfig ];

0 commit comments

Comments
 (0)