-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathwebpack.config.js
59 lines (52 loc) · 1.26 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
// webpack.config.js
var nodeExternals = require('webpack-node-externals')
var path = require('path')
var webpack = require('webpack')
var NODE_TARGET = process.env.NODE_TARGET || 'web'
var output = {
path: path.join(__dirname, '/dist')
}
if (NODE_TARGET === 'web') {
output.filename = 'cozy-client.js'
output.library = 'cozy-client-js'
output.libraryTarget = 'umd'
output.umdNamedDefine = true
} else {
output.filename = 'cozy-client.node.js'
output.libraryTarget = 'commonjs'
}
var config = {
entry: ['isomorphic-fetch', path.join(__dirname, 'src', 'index.js')],
devtool: 'source-map',
target: NODE_TARGET,
output: output,
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /(node_modules|bower_components)/
},
{
test: /\.js$/,
loader: 'standard-loader',
exclude: /node_modules|.tmp\/mocha-webpack/
}
]
},
node: {
'crypto': false
},
resolve: {
root: path.resolve('./src'),
extensions: ['', '.js']
}
}
if (NODE_TARGET === 'node') {
config.externals = [nodeExternals()]
config.plugins = [
new webpack.ProvidePlugin({ 'btoa': 'btoa' }),
new webpack.EnvironmentPlugin(Object.keys(process.env))
]
}
module.exports = config