This repository has been archived by the owner on Apr 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathwebpack.config.js
55 lines (52 loc) · 1.55 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
const path = require('path');
const webpack = require('webpack');
const dependencies = require('./package.json').dependencies;
module.exports = {
entry: {
recommend: `${__dirname}/actions/recommend`,
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].bundle.js',
libraryTarget: 'commonjs',
},
// only package into webpack modules that have been explicitely
// added to dependencies in the package.json.
// The others are expected to come from OpenWhisk.
// http://webpack.github.io/docs/configuration.html#externals
externals: (context, request, callback) => {
if (request.startsWith('@')) {
console.log('...', request, 'is assumed to be an external dependency');
callback(null, `commonjs ${request}`);
} else if (context.indexOf('node_modules') === -1 &&
request.indexOf('/') === -1 &&
!dependencies[request]) {
console.log('...', request, 'is assumed to be an external dependency');
callback(null, `commonjs ${request}`);
} else {
callback();
}
},
module: {
loaders: [
{ test: /\.json$/, loader: 'json-loader' }
],
},
target: 'node',
plugins: [
new webpack.DefinePlugin({
'process.env': {
// Useful to reduce the size of libraries
NODE_ENV: JSON.stringify('production'),
},
}),
// optimizations
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
// new webpack.optimize.UglifyJsPlugin({
// compress: {
// warnings: false,
// },
// }),
],
};