forked from l3wi/mam.client.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
70 lines (67 loc) · 1.42 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
/* global __dirname, require, module*/
const webpack = require('webpack')
const UglifyJsPlugin = webpack.optimize.UglifyJsPlugin
const path = require('path')
const env = require('yargs').argv.env // use --env with webpack 2
var output = env.path !== undefined ? env.path : 'lib/'
var libraryName = 'mam.'
var entry
var target
var outputFile
var rules = [
{
test: /(\.jsx|\.js)$/,
loader: 'babel-loader',
exclude: [/(node_modules|bower_components)/]
}
]
if (env === 'node') {
entry = __dirname + '/src/node.js'
outputFile = libraryName + 'node.js'
target = 'node'
rules.push({
test: /\.rs$/,
loader: 'rust-emscripten-loader',
options: {
release: true
}
})
} else {
entry = __dirname + '/src/web.js'
outputFile = libraryName + 'web.js'
target = 'web'
rules.push({
test: /\.rs$/,
loader: 'rust-wasm-loader',
options: {
release: true,
path: output + '/'
}
})
}
console.log(output)
const config = {
entry: entry,
output: {
path: __dirname + '/' + output,
filename: outputFile,
library: libraryName,
libraryTarget: 'umd',
umdNamedDefine: true
},
module: {
rules: rules
},
resolve: {
modules: [path.resolve('./node_modules'), path.resolve('./src')],
extensions: ['.json', '.js']
},
target: target,
node: {
fs: 'empty',
child_process: 'empty',
path: 'empty'
}
}
console.log(config.output)
module.exports = config