2018-08-10 12:49:26 +02:00
|
|
|
// Copyright BigchainDB GmbH and BigchainDB contributors
|
|
|
|
// SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
|
|
|
// Code is Apache-2.0 and docs are CC-BY-4.0
|
|
|
|
|
2021-03-09 14:20:00 +01:00
|
|
|
/* eslint-disable strict, no-console, object-shorthand, import/no-extraneous-dependencies */
|
2018-07-17 08:51:41 +02:00
|
|
|
|
|
|
|
'use strict'
|
|
|
|
|
|
|
|
const path = require('path')
|
2021-03-09 07:16:51 +01:00
|
|
|
const { merge } = require('webpack-merge')
|
2018-07-17 08:51:41 +02:00
|
|
|
|
|
|
|
const development = require('./webpack.development.js')
|
|
|
|
const production = require('./webpack.production.js')
|
|
|
|
|
|
|
|
const AddVendorsPlugin = require('./plugins/add-vendors-plugin')
|
|
|
|
|
|
|
|
const paths = {
|
|
|
|
entry: path.resolve(__dirname, './src/index.js'),
|
|
|
|
bundle: path.resolve(__dirname, 'dist/browser'),
|
|
|
|
}
|
|
|
|
|
|
|
|
const outputs = (base, env, mapping, overrides) => {
|
|
|
|
const collection = []
|
|
|
|
const library = 'bigchaindb-driver'
|
|
|
|
const windowLibrary = 'BigchainDB'
|
|
|
|
|
|
|
|
let environment = development
|
|
|
|
let ext = 'js'
|
|
|
|
|
|
|
|
if (env === 'production') {
|
|
|
|
environment = production
|
|
|
|
ext = `min.${ext}`
|
|
|
|
}
|
|
|
|
|
|
|
|
Object.entries(mapping).forEach(([target, extension]) => {
|
|
|
|
const filename = `[name].${library}.${extension}.${ext}`
|
|
|
|
|
|
|
|
const compiled = {
|
|
|
|
output: {
|
|
|
|
filename: filename,
|
|
|
|
library: target === 'window' ? windowLibrary : library,
|
|
|
|
libraryTarget: target,
|
|
|
|
path: paths.bundle
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new AddVendorsPlugin(`${library}.${extension}.${ext}`)
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
collection.push(merge(base, environment, compiled, overrides))
|
|
|
|
})
|
|
|
|
|
|
|
|
return collection
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
outputs,
|
|
|
|
paths
|
|
|
|
}
|