| 1 |
import { dirname, resolve } from 'node:path'; |
| 2 |
import { fileURLToPath } from 'node:url'; |
| 3 |
import CopyPlugin from 'copy-webpack-plugin'; |
| 4 |
import MiniCSSExtractPlugin from 'mini-css-extract-plugin'; |
| 5 |
import base from './webpack.config.mjs'; |
| 6 |
|
| 7 |
const __dirname = dirname(fileURLToPath(import.meta.url)); |
| 8 |
|
| 9 |
// Externalizing @wordpress/* is what makes a bundle need WordPress to boot. |
| 10 |
// The manifest and cleaner would rewrite and empty the plugin's own build dir. |
| 11 |
const DROP = [ |
| 12 |
'DependencyExtractionWebpackPlugin', |
| 13 |
'WebpackAssetsManifest', |
| 14 |
'CleanWebpackPlugin', |
| 15 |
// Two instances emit the stylesheet twice, once under a hash nothing reads. |
| 16 |
'MiniCssExtractPlugin', |
| 17 |
'MiniCSSExtractPlugin', |
| 18 |
]; |
| 19 |
|
| 20 |
export default { |
| 21 |
...base, |
| 22 |
entry: { designer: './src/Designer/designer.js' }, |
| 23 |
output: { |
| 24 |
filename: '[name].js', |
| 25 |
path: resolve(__dirname, 'designer-dist'), |
| 26 |
publicPath: './', |
| 27 |
clean: true, |
| 28 |
}, |
| 29 |
plugins: [ |
| 30 |
...base.plugins.filter((p) => !DROP.includes(p.constructor.name)), |
| 31 |
new MiniCSSExtractPlugin({ filename: '[name].css' }), |
| 32 |
new CopyPlugin({ |
| 33 |
patterns: [{ from: 'src/Designer/index.html', to: 'index.html' }], |
| 34 |
}), |
| 35 |
], |
| 36 |
optimization: { |
| 37 |
...base.optimization, |
| 38 |
runtimeChunk: false, |
| 39 |
splitChunks: false, |
| 40 |
}, |
| 41 |
}; |
| 42 |
|