File: /home/zeusxp5/chuair.org/wp-content/themes/lifttruck/webpack.config.js
// WordPress webpack config.
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
const CopyWebpackPlugin = require('copy-webpack-plugin');
const { getWebpackEntryPoints } = require('@wordpress/scripts/utils/config');
// Plugins.
const RemoveEmptyScriptsPlugin = require( 'webpack-remove-empty-scripts' );
const TerserPlugin = require('terser-webpack-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
// Utilities.
const path = require( 'path' );
// Add any a new entry point by extending the webpack config.
module.exports = {
...defaultConfig,
...{
entry: {
...getWebpackEntryPoints(),
'js/editor' : path.resolve( process.cwd(), 'resources/js', 'editor.js' ),
'js/screen' : path.resolve( process.cwd(), 'resources/js', 'screen.js' ),
'js/metabox-fields' : path.resolve( process.cwd(), 'resources/js', 'metabox-fields.js' ),
'css/screen' : path.resolve( process.cwd(), 'resources/scss', 'screen.scss' ),
'css/editor' : path.resolve( process.cwd(), 'resources/scss', 'editor.scss' ),
},
plugins: [
// Include WP's plugin config.
...defaultConfig.plugins,
// Removes the empty `.js` files generated by webpack but
// sets it after WP has generated its `*.asset.php` file.
new RemoveEmptyScriptsPlugin( {
stage: RemoveEmptyScriptsPlugin.STAGE_AFTER_PROCESS_PLUGINS
} ),
new CopyWebpackPlugin({
patterns: [
{from: "resources/images", to: "images"}
],
}),
],
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
parallel: true,
terserOptions: {
ecma: undefined,
warnings: false,
parse: {},
compress: false,
mangle: true,
module: false,
output: {
beautify: true
},
toplevel: false,
nameCache: null,
ie8: false,
keep_fnames: false,
},
}),
new CssMinimizerPlugin()
]
}
}
};