-
Notifications
You must be signed in to change notification settings - Fork 95
/
webpack.deploy.js
42 lines (36 loc) · 1.08 KB
/
webpack.deploy.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
'use strict';
const path = require('path');
const S3Plugin = require('webpack-s3-plugin');
const webpackConfig = require('./webpack.config');
function getBasePath(extension) {
return path.join(require('./package').version, extension || '');
}
function getConfig(config) {
const plugins = config.plugins;
const extendedPlugins = plugins.concat([
new S3Plugin({
s3Options: {
region: process.env.AWS_REGION
},
s3UploadOptions: {
Bucket: process.env.AWS_S3_BUCKET
},
basePathTransform: getBasePath,
include: /index\.html$/
}),
new S3Plugin({
s3Options: {
region: process.env.AWS_REGION
},
s3UploadOptions: {
Bucket: process.env.AWS_S3_BUCKET
},
basePathTransform: getBasePath.bind(null, 'public'),
directory: 'public'
})
]);
return Object.assign({}, config, {
plugins: extendedPlugins
});
}
module.exports = getConfig(webpackConfig);