2018-11-26 15:55:09 +01:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
const path = require('path')
|
|
|
|
const merge = require('webpack-merge')
|
|
|
|
|
|
|
|
const development = require('./webpack.development.js')
|
|
|
|
const production = require('./webpack.production.js')
|
|
|
|
|
|
|
|
const AddVendorsPlugin = require('./plugins/add-vendors-plugin')
|
|
|
|
|
|
|
|
const paths = {
|
2018-11-28 12:12:58 +01:00
|
|
|
entry: path.resolve(__dirname, './dist/node/squid.js'),
|
2019-06-20 00:20:09 +02:00
|
|
|
bundle: path.resolve(__dirname, 'dist/browser')
|
2018-11-26 15:55:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const outputs = (base, env, mapping, overrides) => {
|
|
|
|
const collection = []
|
|
|
|
const library = 'squid'
|
|
|
|
const windowLibrary = 'Squid'
|
|
|
|
|
|
|
|
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
|
|
|
|
},
|
2019-06-20 00:20:09 +02:00
|
|
|
plugins: [new AddVendorsPlugin(`${library}.${extension}.${ext}`)]
|
2018-11-26 15:55:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
collection.push(merge(base, environment, compiled, overrides))
|
|
|
|
})
|
|
|
|
|
|
|
|
return collection
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
outputs,
|
|
|
|
paths
|
|
|
|
}
|