Add Webpack config for @mailpoet/components

[MAILPOET-5015]
This commit is contained in:
Jan Jakes
2023-01-26 13:55:16 +01:00
committed by Jan Jakeš
parent 093814eaa7
commit 2aaf01fe11
2 changed files with 112 additions and 0 deletions

View File

@ -0,0 +1,32 @@
import path from 'node:path';
import { default as defaultConfig } from '@wordpress/scripts/config/webpack.config.js';
import { WebpackEmitAllPlugin } from '../../../tools/webpack/webpack-emit-all-plugin.js';
const dirname = new URL('.', import.meta.url).pathname;
const plugins = [
...defaultConfig.plugins.filter(
(plugin) => plugin.constructor.name !== 'DependencyExtractionWebpackPlugin',
),
new WebpackEmitAllPlugin({ context: path.join(dirname, 'src') }),
];
export default {
...defaultConfig,
plugins,
devtool: 'source-map',
context: dirname,
entry: { index: path.join(dirname, 'src', 'index.ts') },
output: {
...defaultConfig.output,
path: path.join(dirname, 'build-module'),
environment: { module: true },
library: { type: 'module' },
},
externals: {
react: 'React',
'react-dom': 'ReactDOM',
'react/jsx-runtime': 'ReactJSX',
},
experiments: { outputModule: true },
};