Webpack S3 Plugin
Learn how to configure Webpack S3 Plugin for use with Filebase.

What is Webpack S3 Plugin?

Webpack is an open-source JavaScript module bundling package. It’s primarily for JavaScript, but it can be used with HTML, CSS, and image files for front-end development. A variety of webpack plugins have been developed and released for use, including an S3-compatible plugin.
Read below to learn how to use the Webpack S3 Plugin with Filebase.

Prerequisites:

This guide shows a sample configuration and how to connect a Webpack configuration to Filebase. Filebase is unable to provide debugging for custom configurations due to their individualized nature.

1. Download the Webpack S3 Plugin:

npm i webpack-s3-plugin

2. Based on your Webpack configuration, input the following code in the desired configuration or index file.

This example excludes all .html files from upload:
1
var S3Plugin = require('webpack-s3-plugin')
2
3
var config = {
4
plugins: [
5
new S3Plugin({
6
directory: '/path/to/directory/to/upload',
7
// Exclude uploading of html
8
exclude: /.*\\.html$/,
9
// s3Options are required
10
s3Options: {
11
accessKeyId: 'filebase-access-key',
12
secretAccessKey: 'filebase-secret-key',
13
region: 'us-east-1',
14
endpoint: 's3.filebase.com',
15
signatureVersion: ‘v4’
16
},
17
s3UploadOptions: {
18
Bucket: 'filebase-bucket-name'
19
},
20
})
21
]
22
}
Copied!
Replace the following values to match your configuration:
  • Directory: Directory where files to be uploaded are stored.
  • Exclude: Determine the file type you want to exclude from upload. All other file types will be included.
  • AccessKeyId: Filebase Access Key
  • SecretAccessKey: Filebase Secret Key
  • Bucket: Filebase Bucket Name

3. This example includes all .css and .js files in the upload:

1
var S3Plugin = require('webpack-s3-plugin')
2
3
var config = {
4
plugins: [
5
new S3Plugin({
6
directory: '/path/to/directory/to/upload',
7
// Only upload css and js
8
include: /.*\\.(css|js)/,
9
// s3Options are required
10
s3Options: {
11
accessKeyId: 'filebase-access-key',
12
secretAccessKey: 'filebase-secret-key',
13
region: 'us-east-1',
14
endpoint: 's3.filebase.com',
15
signatureVersion: ‘v4’
16
},
17
s3UploadOptions: {
18
Bucket: 'filebase-bucket-name'
19
},
20
})
21
]
22
}
Copied!
Replace the following values to match your configuration:
  • Directory: Directory where files to be uploaded are stored.
  • Include: Determine the file type you want to include in upload. All other file types will be included.
  • AccessKeyId: Filebase Access Key
  • SecretAccessKey: Filebase Secret Key
  • Bucket: Filebase Bucket Name

4. Run your Webpack project:

npx webpack
If you have any questions, please join our Discord server, or send us an email at [email protected]