Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function buildBundle (config, isDevelopment) {
const entry = {}
const commandEntryFile = await createCommandEntryFile(config)
if (commandEntryFile !== null) {
const key = extractBasename(constants.build.pluginCodeFilePath)
entry[key] = commandEntryFile
}
const uiEntryFile = await createUiEntryFile(config)
if (uiEntryFile !== null) {
const key = extractBasename(constants.build.pluginUiFilePath)
entry[key] = uiEntryFile
}
let webpackConfig = createWebpackConfig(entry, isDevelopment)
const customWebpackConfigPath = await findUp(constants.configFileName)
if (typeof customWebpackConfigPath !== 'undefined') {
webpackConfig = require(customWebpackConfigPath)(webpackConfig)
}
return new Promise(function (resolve, reject) {
webpack(webpackConfig, async function (error, stats) {
if (stats.hasErrors() === true) {
reject(stats.toJson().errors.join('\n'))
return
}
if (error) {
reject(error)
return
}
resolve()
})
})