It used to output two files, the .js and the -umd.js file.
I updated a few things and for some reason now it only outputs the first one on the exports array.
If I change the order, it will only import the -umd.js one.
Using:
npm 7.24.0
node 14.16.0
"webpack": "5.52.0",
"webpack-cli": "4.8.0",
"webpack-dev-server": "4.1.0",
"webpack-merge": "5.8.0"
const path = require('path');
const { merge } = require('webpack-merge');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const webpackConfig = require('./webpack.config');
const dirApp = path.join(__dirname, 'components');
const shared = {
entry: {
bundle: path.join(dirApp, 'index'),
},
optimization: {
minimize: false,
},
plugins: [new CleanWebpackPlugin()],
};
module.exports = [
merge(webpackConfig, shared, {
// node module aliases
externals: {
react: 'react',
'react-dom': 'react-dom',
},
output: {
path: path.join(__dirname, 'dist'),
filename: 'react-demo.js',
library: 'Reactdemo',
libraryTarget: 'commonjs2',
},
}),
merge(webpackConfig, shared, {
externals: {
// window aliases
react: 'React',
'react-dom': 'ReactDOM',
},
output: {
path: path.join(__dirname, 'dist'),
filename: 'react-demo-umd.js',
library: 'Reactdemo',
libraryTarget: 'umd',
umdNamedDefine: true,
},
}),
];