forked from NebulousLabs/Sia-UI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
84 lines (76 loc) · 1.9 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
'use strict'
const webpack = require('webpack')
const path = require('path')
const glob = require('glob')
const version = require('./package.json').version
function isVendor(args) {
const resource = args.resource
return resource &&
resource.indexOf('node_modules') >= 0 &&
resource.match(/\.(js|json)$/)
}
// Compute the entry-points for Sia-UI.
const entrypoints = {}
const plugins = glob.sync('./plugins/*/js/index.js')
plugins.forEach((plugin) => {
entrypoints[path.dirname(path.dirname(plugin))] = ['babel-polyfill', path.resolve('./js/rendererjs/pluginapi.js'), plugin]
})
entrypoints['renderer'] = ['babel-polyfill', path.resolve('./js/rendererjs/index.js')]
const common = {
output: {
path: path.resolve('./dist'),
filename: '[name].js',
publicPath: 'dist/',
},
resolve: {
modules: [path.resolve('./node_modules')],
},
node: {
global: true,
__dirname: false,
__filename: false,
},
module: {
// this noParse is to deal with an issue with validate.js not being packed properly.
// see this issue: https://github.com/webpack/webpack/issues/138 for more information.
noParse: /node_modules\/json-schema\/lib\/validate\.js/,
rules: [
{
test: /\.js?$/,
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true,
},
},
exclude: /node_modules/,
},
],
},
}
const main = Object.assign({}, {
entry: [path.resolve('./js/mainjs/index.js')],
plugins: [
new webpack.DefinePlugin({
VERSION: JSON.stringify(version),
}),
],
target: 'electron-main',
}, common)
const renderer = Object.assign({}, {
entry: entrypoints,
plugins: [
new webpack.DefinePlugin({
VERSION: JSON.stringify(version),
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: isVendor,
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
}),
],
target: 'electron-renderer',
}, common)
module.exports = [ main, renderer ]