I recently split my webpack builds into separate config files and merge them with a common one.
The only difference between the configurations besides the mode
is a globally defined BASE_URL
const merge = require('webpack-merge');
const common = require('./webpack.common.js');
const DefinePlugin = require('webpack').DefinePlugin;
module.exports = merge(common, {
mode: 'development',
devtool: 'inline-source-map',
plugins: [
new DefinePlugin({
BASE_URL: JSON.stringify('http://localhost:5000')
})
]
})
Prior to doing this, I was using a single webpack.config and the --mode production
option from the CLI.
In my code, I can see the proper BASE_URL
in both bundles, but only the development
one works; the other throws the error: Error: Attempted to register an Element when one with the same name already exists. Name: n.
which is very unhelpful, since I don't have an element with the name of n
.
EDIT: The error appears to be occuring during the autoregistration of global resources, specifically, for this my DateFormat
value converter:
date-format.ts
export class DateFormatValueConverter {
toView(value: string) {
return new Date(value).toLocaleString();
}
}
index.ts
import { FrameworkConfiguration } from 'aurelia-framework';
import { DateInputFormatValueConverter } from './value-converters/date-input-format';
import { DateFormatValueConverter } from './value-converters/date-format';
export function configure(config: FrameworkConfiguration) {
config.globalResources(
[
DateInputFormatValueConverter,
DateFormatValueConverter
]
)
}
EDIT2: It appears to be anything that is resourced globally, except for the first entry.
EDIT3: It seems that if I declare global resources via strings (and PLATFORM.moduleName
) works. This may be something the Aurelia team should look into.
export function configure(config: FrameworkConfiguration) {
config.globalResources(
[
PLATFORM.moduleName('./value-converters/date-input-format'),
PLATFORM.moduleName('./value-converters/date-format'),
PLATFORM.moduleName('./value-converters/delay-format'),
...
]
)
}