forked from adieuadieu/retinal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
46 lines (43 loc) · 1.33 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
const path = require('path')
const decompress = require('decompress')
const webpack = require('webpack')
const sharpTarball = path.join(__dirname, 'lib/sharp-0.17.3-aws-linux-x64-node-6.10.1.tar.gz')
const webpackDir = path.join(__dirname, '.webpack/')
function ExtractTarballPlugin (archive, to) {
return {
apply: (compiler) => {
compiler.plugin('emit', (compilation, callback) => {
decompress(path.resolve(archive), path.resolve(to))
.then(() => callback())
.catch(error => console.error('Unable to extract archive ', archive, to, error.stack))
})
},
}
}
module.exports = {
entry: './src/handler',
target: 'node',
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel',
include: __dirname,
exclude: /node_modules/,
},
{ test: /\.json$/, loader: 'json-loader' },
],
},
output: {
libraryTarget: 'commonjs',
path: '.webpack',
filename: 'handler.js', // this should match the first part of function handler in serverless.yml
},
externals: ['sharp', 'aws-sdk'],
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.DedupePlugin(),
// new webpack.optimize.UglifyJsPlugin({ minimize: true, sourceMap: false, warnings: false }),
new ExtractTarballPlugin(sharpTarball, webpackDir),
],
}