-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.js
More file actions
59 lines (55 loc) · 1.67 KB
/
webpack.config.js
File metadata and controls
59 lines (55 loc) · 1.67 KB
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
const path = require('path')
const decompress = require('decompress')
const webpack = require('webpack')
const CleanWebpackPlugin = require('clean-webpack-plugin'); //installed via npm
const nodeExternals = require('webpack-node-externals');
const slsw = require('serverless-webpack');
const sharpTarball = path.resolve(
__dirname,
`lambda-sharp/sharp.tar.gz`
)
const webpackDir = path.resolve(__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: slsw.lib.entries,
// entry: './handler',
target: 'node',
mode: slsw.lib.webpack.isLocal ? "development" : "production",
module: {
rules: [
{
test: /\.js$/,
include: __dirname,
exclude: /node_modules/,
use: [ 'babel-loader' ]
},
{
test: /\.json$/,
use: [ 'json-loader' ]
}
]
},
output: {
libraryTarget: 'commonjs',
path: path.resolve(__dirname, '.webpack'),
filename: '[name].js', // this should match the first part of function handler in serverless.yml
},
externals: [nodeExternals()],
plugins: [
// new CleanWebpackPlugin(path.join(__dirname, '.webpack/node_modules')),
// new webpack.optimize.OccurenceOrderPlugin(),
// new webpack.optimize.DedupePlugin(),
// new webpack.optimize.UglifyJsPlugin({ minimize: true, sourceMap: false, warnings: false }),
// new ExtractTarballPlugin(sharpTarball, webpackDir),
],
}