PluginProbe ʕ •ᴥ•ʔ
Really Simple Security – Simple and Performant Security (formerly Really Simple SSL) / 9.5.11
Really Simple Security – Simple and Performant Security (formerly Really Simple SSL) v9.5.11
9.5.11 9.5.10.1 9.5.10 trunk 9.4.0 9.4.1 9.4.2 9.4.3 9.5.0 9.5.0.1 9.5.0.2 9.5.1 9.5.2 9.5.2.2 9.5.2.3 9.5.3 9.5.3.1 9.5.3.2 9.5.4 9.5.5 9.5.6 9.5.7 9.5.8 9.5.9
really-simple-ssl / settings / webpack.feature.config.js
really-simple-ssl / settings Last commit date
build 4 weeks ago config 4 weeks ago src 4 weeks ago index.php 4 weeks ago settings.php 4 weeks ago webpack.config.js 4 weeks ago webpack.feature.config.js 4 weeks ago
webpack.feature.config.js
108 lines
1 const path = require('path');
2 const defaultConfig = require("@wordpress/scripts/config/webpack.config");
3 const featureFolders = ['two-fa']; // Add more folders as needed
4 const isProduction = true;
5 const { ProvidePlugin, Compilation } = require('webpack');
6 const fs = require('fs');
7 const MiniCssExtractPlugin = require('mini-css-extract-plugin');
8 const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
9
10 module.exports = {
11 mode: 'production',
12 ...defaultConfig,
13 entry: featureFolders.reduce((entries, folder) => {
14 const jsPath = path.resolve(__dirname, `../security/wordpress/${folder}/assets/js/index.js`);
15 const scssPath = path.resolve(__dirname, `../security/wordpress/${folder}/assets/css/${folder}.scss`);
16 // check if the file exists
17 if (fs.existsSync(jsPath)) {
18 entries[`${folder}/assets`] = jsPath;
19 } else {
20 console.error(`File ${jsPath} does not exist`);
21 }
22 if (fs.existsSync(scssPath)) {
23 entries[`${folder}/styles`] = scssPath;
24 } else {
25 console.error(`File ${scssPath} does not exist`);
26 }
27 return entries;
28 }, {}),
29 output: {
30 path: path.resolve(__dirname, `../assets/features/`), // Output to the features directory
31 filename: '[name].min.js',
32 clean: false,
33 },
34 // disable source maps to prevent invalid JSON errors in RtlCssPlugin
35 devtool: false,
36 resolve: {
37 ...defaultConfig.resolve,
38 modules: [
39 path.resolve(__dirname, '../settings/node_modules'), // Look in settings' node_modules
40 path.resolve(__dirname, '../node_modules'), // Look in the root node_modules
41 'node_modules', // Fallback to default node_modules
42 ],
43 fallback: {
44 "path": require.resolve("path-browserify"),
45 "stream": require.resolve("stream-browserify"),
46 "buffer": require.resolve("buffer/"),
47 },
48 },
49 module: {
50 ...defaultConfig.module,
51 rules: [
52 // remove default CSS/SCSS rules, including those in oneOf blocks
53 ...defaultConfig.module.rules.flatMap(rule => {
54 if (rule.oneOf) {
55 return [{
56 ...rule,
57 oneOf: rule.oneOf.filter(r => !(r.test && (r.test.test('.css') || r.test.test('.scss')))),
58 }];
59 }
60 if (rule.test && (rule.test.test('.css') || rule.test.test('.scss'))) {
61 return [];
62 }
63 return [rule];
64 }),
65 {
66 test: /\.js$/,
67 exclude: /node_modules/,
68 use: {
69 loader: 'babel-loader',
70 options: { presets: ['@babel/preset-env'] },
71 },
72 },
73 {
74 test: /\.(css|scss)$/i,
75 use: [
76 MiniCssExtractPlugin.loader,
77 'css-loader',
78 'sass-loader'
79 ],
80 },
81 ],
82 },
83 plugins: [
84 // keep default plugins except the RtlCssPlugin to avoid source-map parsing errors
85 ...defaultConfig.plugins.filter(plugin => plugin.constructor && plugin.constructor.name !== 'RtlCssPlugin'),
86 new ProvidePlugin({
87 Buffer: ['buffer', 'Buffer'],
88 process: 'process/browser',
89 }),
90 new MiniCssExtractPlugin({
91 filename: '[name].min.css',
92 }),
93 ],
94 optimization: {
95 ...defaultConfig.optimization,
96 splitChunks: false,
97 minimize: isProduction,
98 minimizer: [
99 '...',
100 new CssMinimizerPlugin(),
101 ],
102 },
103 stats: {
104 errors: true,
105 moduleTrace: true,
106 errorDetails: true,
107 },
108 };