-
Notifications
You must be signed in to change notification settings - Fork 10
/
webpack.config.js
executable file
·50 lines (47 loc) · 1.2 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 slsw = require('serverless-webpack')
const nodeExternals = require('webpack-node-externals')
const path = require('path')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const ConditionalPlugin = (condition, plugin) => ({
apply: compiler => {
const name = Object.keys(compiler.options.entry)[0].split('/').pop()
const config = Object.assign({webpack: {}}, slsw.lib.serverless.service.getFunction(name))
if (condition(config))
plugin.apply(compiler)
}
})
module.exports = {
stats: 'minimal',
entry: slsw.lib.entries,
output: {
libraryTarget: 'commonjs-module',
path: path.resolve(__dirname, '.webpack'),
filename: '[name].js',
},
target: 'node',
devtool: 'source-map',
externals: [nodeExternals()],
mode: slsw.lib.webpack.isLocal ? 'development' : 'production',
optimization: {
minimize: true
},
performance: {
hints: false
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
include: __dirname,
exclude: /node_modules/
}
]
},
plugins: [
ConditionalPlugin(
((config) => config.webpack.toml),
new CopyWebpackPlugin({patterns: [{ from: 'stellar.toml' }]})
)
]
}