You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

51 lines
1.2 KiB

const path = require('path')
const fs = require('fs')
const webpack = require('webpack')
const webpackMain = require('electron-webpack/webpack.main.config') // eslint-disable-line import/no-extraneous-dependencies
const define = require('./define')
const dirs = p =>
fs
.readdirSync(p)
.filter(f => fs.statSync(path.join(p, f)).isDirectory())
.map(d => path.resolve(__dirname, `${p}/${d}`))
.reduce((result, value) => {
const [key] = value.split('/').slice(-1)
result[key] = value
return result
}, {})
module.exports = webpackMain().then(config => ({
target: 'electron-main',
entry: dirs(path.resolve(__dirname, '../src/internals')),
resolve: {
extensions: ['.js', '.json', '.node'],
},
externals: ['node-hid', ...config.externals],
output: {
path: path.resolve(__dirname, '../dist/internals'),
filename: '[name].js',
libraryTarget: 'commonjs2',
},
module: {
rules: [
{
test: /\.js$/,
use: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.node$/,
use: 'node-loader',
},
],
},
plugins: [define, new webpack.optimize.ModuleConcatenationPlugin()],
}))