forked from ravendesignsystem/rds
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.release.js
More file actions
143 lines (133 loc) · 3.09 KB
/
webpack.release.js
File metadata and controls
143 lines (133 loc) · 3.09 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/**
* WordPress Webpack Config
*/
require('dotenv').config();
const merge = require('webpack-merge');
const baseConfig = require('./webpack.config.js');
const FileManagerPlugin = require('filemanager-webpack-plugin');
const S3Plugin = require('webpack-s3-plugin');
const version = '0.20.0';
// Build Config
module.exports = merge(baseConfig, {
plugins: [
// Build dist for npm package
new FileManagerPlugin({
onStart: {
delete: [
'./dist/_blocks',
'./dist/_components',
'./dist/_core',
// './dist/' + version,
],
},
onEnd: {
copy: [
{
source: './build/docs/css/core.*',
destination: './dist/' + version,
},
{
source: './build/docs/js/core.*',
destination: './dist/' + version,
},
{
source: './src/_blocks/**/*.scss',
destination: './dist/_blocks',
},
{
source: './src/_blocks/**/*.js',
destination: './dist/_blocks',
},
{
source: './src/_components/**/*.scss',
destination: './dist/_components',
},
{
source: './src/_components/**/*.js',
destination: './dist/_components',
},
{
source: './src/_components/icons/*.svg',
destination: './dist/_components/icons',
},
{
source: './src/_core',
destination: './dist/_core',
},
],
},
}),
new S3Plugin({
include: /.*\.(css.gz|js.gz|map.gz)/,
s3Options: {
accessKeyId: process.env.AWS_ACCESS_KEY,
secretAccessKey: process.env.AWS_SECRET_KEY,
region: 'us-east-1',
},
s3UploadOptions: {
Bucket: process.env.AWS_CDN_BUCKET,
// Set content encoding for gzip files
ContentEncoding(fileName) {
if (/\.gz/.test(fileName)) {
return 'gzip';
}
},
// Set content types for css and js
ContentType(fileName) {
if (/\.css/.test(fileName)) {
return 'text/css';
}
if (/\.js/.test(fileName)) {
return 'application/javascript';
}
},
// Set expiry date on all items
Expires() {
return new Date(Date.now() + 63072000000);
},
//Set permission level on all items
ACL() {
return 'public-read';
},
},
directory: 'dist/latest',
basePath: 'rds/' + version,
}),
new S3Plugin({
include: /.*\.(css.gz|js.gz|map.gz)/,
s3Options: {
accessKeyId: process.env.AWS_ACCESS_KEY,
secretAccessKey: process.env.AWS_SECRET_KEY,
region: 'us-east-1',
},
s3UploadOptions: {
Bucket: process.env.AWS_CDN_BUCKET,
// Set content encoding for gzip files
ContentEncoding(fileName) {
if (/\.gz/.test(fileName)) {
return 'gzip';
}
},
// Set content types for css and js
ContentType(fileName) {
if (/\.css/.test(fileName)) {
return 'text/css';
}
if (/\.js/.test(fileName)) {
return 'application/javascript';
}
},
// Set expiry date on all items
Expires() {
return new Date(Date.now() + 63072000000);
},
//Set permission level on all items
ACL() {
return 'public-read';
},
},
directory: 'dist/latest',
basePath: 'rds/latest',
}),
],
});