maybe you can take a look at https://github.com/mendixlabs/list-view-controls/blob/master/src/package.xml
Ive managed to get this sort of working by having quite a few overrides in a custom webpack file:
const path = require('path');
const merge = require('webpack-merge');
const baseConfig = require('./node_modules/@mendix/pluggable-widgets-tools/configs/webpack.config.dev.js'); //Can also be webpack.config.prod.js
const variables = require('./node_modules/@mendix/pluggable-widgets-tools/configs/variables');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const packagePath = variables.package.packagePath.replace(/\./g, '\/');
const widgetName = variables.package.widgetName;
const name = widgetName.toLowerCase();
/**
* This webpack file adds some overrides to the standard webpack file from the pluggable widgets tools.
* This is necessary to prevent build time issues with the local modules (amewidgets/ameplot) in relation
* to react-dom & react-hot-loader
*/
const customConfig = {
entry: {
TestWidget: path.join(variables.path, `/src/TestWidget/TestWidget.${variables.extension}`),
TestWidget2: path.join(variables.path, `/src/TestWidget2/TestWidget2.${variables.extension}`),
},
output: {
path: path.join(variables.path, '/dist/tmp'),
filename: `widgets/${packagePath}/${name}/[name].js`,
libraryTarget: 'umd',
publicPath: '/'
},
plugins: [
new CopyWebpackPlugin(
[{
from: path.join(variables.path, 'src/**/*.xml'),
toType: 'template',
to: 'widgets/[name]/[name].[ext]',
ignore: 'src/package.xml'
}],
{ copyUnmodified: true }
),
]
};
const previewConfig = {
entry: {
TestWidget: path.join(variables.path, `/src/TestWidget/TestWidget.webmodeler.${variables.extension}`),
TestWidget2: path.join(variables.path, `/src/TestWidget2/TestWidget2.webmodeler.${variables.extension}`),
},
output: {
path: path.join(variables.path, '/dist/tmp'),
filename: 'widgets/[name]/[name].webmodeler.js',
libraryTarget: 'commonjs'
}
};
module.exports = [merge(baseConfig[0], customConfig), merge(baseConfig[1], previewConfig)];
I presume I would also need to do this for webpack.config.prod.js?
Its not fully working as the webmodeler preview file doesnt appear in the generated .mpk file. No idea why. Not a blocking issue for us though (widget is still usable)
It seems to me that being set up for multiple widgets in a pluggable widget package should be the default for the pluggable-widget-tools module, since there would be no problem having just 1 widget in a multi-widget package.
Whereas going the other way and extending a single widget package to multi widgets involves heavy customisations.
Hi
I have also come across this problem. I tried to follow list-view-controls, but it does not use the ‘pluggable-widget-tools’ package so I believe the configuration is different. There is also the ‘Charts’ package which has multiple widgets, but again the configuration is different.
It seems that:
Did you ever get this issue sorted and/or does anyone know the definitive list of changes needed (from the boilerplate setup by yeoman) to have multiple widgets per package?
same asking, do we have any mendix expert can provide some best practice to group widgets and share code between them?