-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-webpack-config.js
40 lines (37 loc) · 1.16 KB
/
make-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
const webpack = require('webpack');
const path = require('path');
const ZipPlugin = require('zip-webpack-plugin');
const Environment = require('./Environment');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const makeConfig = (environment = Environment.PRODUCTION) => {
process.env['NODE_ENV'] = environment;
const plugins = [
new ZipPlugin() // if you just have js you can copy and paste the output js into your lambda function,
// but if you have assets you'll need the zip file
];
if (environment === Environment.PRODUCTION) {
plugins.unshift(new UglifyJSPlugin);
}
const config = {
entry: './src/index.js',
output: {
path: path.join(__dirname, 'dist'),
libraryTarget: 'commonjs2',
library: 'alexaApp',
filename: 'index.js'
},
target: 'node',
module: {
rules: [
{
use: 'babel-loader',
test: /\.js$/,
exclude: /node_modules/
}
]
},
plugins: plugins
};
return config;
};
module.exports = makeConfig;