forked from adieuadieu/serverless-chrome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
50 lines (47 loc) · 1.39 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
const path = require('path')
const decompress = require('decompress')
const webpack = require('webpack')
const chromeTarball = path.join(__dirname, 'chrome/chrome-headless-lambda-linux-x64.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',
entry: './src/handler',
target: 'node',
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel',
include: __dirname,
exclude: /node_modules/,
},
{ test: /\.json$/, loader: 'json-loader' },
],
},
resolve: {
root: __dirname,
},
output: {
libraryTarget: 'commonjs',
path: '.webpack',
filename: 'handler.js', // this should match the first part of function handler in serverless.yml
},
externals: ['aws-sdk'],
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.DedupePlugin(),
// new webpack.optimize.UglifyJsPlugin({ minimize: true, sourceMap: false, warnings: false }),
new ExtractTarballPlugin(chromeTarball, webpackDir),
],
}