-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.config.js
executable file
·76 lines (70 loc) · 1.74 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
var webpack = require('webpack');
var UglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
var path = require('path');
var env = require('yargs').argv.mode;
var version = require('yargs').argv.version;
var nodeExternals = require('webpack-node-externals');
if (!version) {
version = 'client';
}
var plugins = [
new webpack.ContextReplacementPlugin(/.*/, path.resolve(__dirname, 'node_modules', 'jsondiffpatch'), {
'../package.json': './package.json',
'./formatters': './src/formatters/index.js',
'./console': './src/formatters/console.js'
})
];
var outputFile = `telepat.${version}`;
plugins.push(new webpack.DefinePlugin({ 'global.GENTLY': false }));
if (env === 'dev') {
outputFile += '.js';
} else {
plugins.push(new UglifyJsPlugin({ minimize: true }));
outputFile += '.min.js';
}
var config = {
entry: __dirname + '/src/telepat.js',
target: version === 'server' ? 'node' : 'web',
devtool: 'source-map',
output: {
path: __dirname + '/lib',
filename: outputFile,
library: 'Telepat',
libraryTarget: 'umd',
umdNamedDefine: true
},
externals: version === 'server'? {
'pouchdb':"pouchdb",
'leveldown':"leveldown"
} : {},
module: {
loaders: [
{
test: /(\.js)$/,
loader: 'babel',
exclude: /(node_modules|bower_components)/
},
{
test: /(\.js)$/,
loader: 'eslint-loader',
exclude: /node_modules/
},
{
test: /(\.json)$/,
loader: 'json'
}
]
},
resolve: {
root: path.resolve('./src'),
extensions: ['', '.js', '.json'],
alias: {
'../package.json': './node_modules/jsondiffpatch/package.json'
}
},
node: {
__dirname: true
},
plugins: plugins,
};
module.exports = config;